-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Monolog] Added documentation about ElasticsearchLogstashHandler #12201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
Handlers | ||
======== | ||
|
||
ElasticsearchLogstashHandler | ||
---------------------------- | ||
|
||
.. versionadded:: 4.4 | ||
|
||
The ``ElasticsearchLogstashHandler`` was introduced in Symfony 4.4. | ||
|
||
This handler deals directly with the HTTP interface of Elasticsearch. This means | ||
it will slow down your application if Elasticsearch takes times 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: | ||
|
||
|
||
lyrixx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.. configuration-block:: | ||
|
||
.. code-block:: yaml | ||
|
||
# config/services.yaml | ||
services: | ||
Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler: ~ | ||
|
||
.. code-block:: xml | ||
|
||
<!-- config/services.xml --> | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:monolog="http://symfony.com/schema/dic/monolog" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services | ||
https://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/monolog | ||
https://symfony.com/schema/dic/monolog/monolog-1.0.xsd"> | ||
|
||
<services> | ||
<service id="Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler"/> | ||
</services> | ||
</container> | ||
|
||
.. code-block:: php | ||
|
||
// config/services.php | ||
use App\Logger\SessionRequestProcessor; | ||
use Monolog\Formatter\LineFormatter; | ||
use Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler; | ||
|
||
$container->register(ElasticsearchLogstashHandler::class); | ||
|
||
Then reference it in monolog configuration: | ||
|
||
|
||
lyrixx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.. configuration-block:: | ||
|
||
.. code-block:: yaml | ||
|
||
# config/packages/prod/monolog.yaml | ||
monolog: | ||
handlers: | ||
es: | ||
type: service | ||
id: Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler | ||
|
||
.. code-block:: xml | ||
|
||
<!-- config/packages/prod/monolog.xml --> | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:monolog="http://symfony.com/schema/dic/monolog" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services | ||
https://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/monolog | ||
https://symfony.com/schema/dic/monolog/monolog-1.0.xsd"> | ||
|
||
<monolog:config> | ||
<monolog:handler | ||
name="es" | ||
type="service" | ||
id="Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler" | ||
/> | ||
</monolog:config> | ||
</container> | ||
|
||
.. code-block:: php | ||
|
||
use Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler; | ||
// config/packages/prod/monolog.php | ||
lyrixx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$container->loadFromExtension('monolog', [ | ||
'handlers' => [ | ||
'es' => [ | ||
'type' => 'service', | ||
'id' => ElasticsearchLogstashHandler::class, | ||
], | ||
], | ||
]); | ||
lyrixx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. _`ELK stack`: https://www.elastic.co/what-is/elk-stack |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.