Handlers
Edit this pageHandlers
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.
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.
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.
To use it, declare it as a service:
- YAML
- XML
- PHP
1 2 3
# config/services.yaml
services:
Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler: ~
Then reference it in the Monolog configuration:
- YAML
- XML
- PHP
1 2 3 4 5 6
# config/packages/prod/monolog.yaml
monolog:
handlers:
es:
type: service
id: Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler
This work, including the code samples, is licensed under a
Creative Commons BY-SA 3.0
license.