Handlers

ElasticsearchLogstashHandler

This handler deals directly with the HTTP interface of Elasticsearch. This means it will slow down your application if Elasticsearch takes time to answer. Even if all HTTP calls are done asynchronously.

このハンドラーは、Elasticsearch の HTTP インターフェースを直接処理します。これは、Elasticsearch が応答するのに時間がかかる場合、アプリケーションの速度が低下することを意味します。すべての HTTP 呼び出しが非同期で行われたとしても。

In a development environment, it's fine to keep the default configuration: for each log, an HTTP request will be made to push the log to Elasticsearch.

開発環境では、デフォルトの構成を維持しても問題ありません。foreach ログでは、ログを Elasticsearch にプッシュするための HTTP 要求が行われます。

In a production environment, it's highly recommended to wrap this handler in a handler with buffering capabilities (like the FingersCrossedHandler or BufferHandler) in order to call Elasticsearch only once with a bulk push. For even better performance and fault tolerance, a proper ELK stack is recommended.

実稼働環境では、一括プッシュで Elasticsearch を 1 回だけ呼び出すために、バッファリング機能を持つハンドラー (FingersCrossedHandler または BufferHandler など) でこのハンドラーをラップすることを強くお勧めします。パフォーマンスと耐障害性をさらに高めるには、適切な ELK スタックをお勧めします。

To use it, declare it as a service:

これを使用するには、サービスとして宣言します。
  • YAML
    YAML
  • XML
    XML
  • PHP
    PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
# config/services.yaml
services:
    Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler: ~

    # optionally, configure the handler using the constructor arguments (shown values are default)
    Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler: ~
        arguments:
            $endpoint: "http://127.0.0.1:9200"
            $index: "monolog"
            $client: null
            $level: !php/const Monolog\Logger::DEBUG
            $bubble: true
            $elasticsearchVersion: '1.0.0'

Then reference it in the Monolog configuration:

次に、Monolog 構成でそれを参照します。
  • YAML
    YAML
  • XML
    XML
  • PHP
    PHP
1
2
3
4
5
6
# config/packages/prod/monolog.yaml
monolog:
    handlers:
        es:
            type: service
            id: Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler