Skip to content

Commit fcb9e8f

Browse files
committed
minor #15524 Example remote ElasticsearchLogstashHandler (pedroresende)
This PR was submitted for the 5.4 branch but it was merged into the 4.4 branch instead. Discussion ---------- Example remote `ElasticsearchLogstashHandler` I've decided to contribute with an example on how to configure a remote server for ElasticsearchLogstashHandler Commits ------- 9d762e7 Example remote ElasticsearchLogstashHandler
2 parents 4900291 + 9d762e7 commit fcb9e8f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

logging/handlers.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ To use it, declare it as a service:
3030
services:
3131
Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler: ~
3232
33+
# optionally, configure the handler using the constructor arguments (shown values are default)
34+
Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler: ~
35+
arguments:
36+
$endpoint: "http://127.0.0.1:9200"
37+
$index: "monolog"
38+
$client: null
39+
$level: !php/const Monolog\Logger::DEBUG
40+
$bubble: true
41+
3342
.. code-block:: xml
3443
3544
<!-- config/services.xml -->
@@ -44,16 +53,37 @@ To use it, declare it as a service:
4453
4554
<services>
4655
<service id="Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler"/>
56+
57+
<!-- optionally, configure the handler using the constructor arguments (shown values are default) -->
58+
<service id="Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler">
59+
<argument key="endpoint">http://127.0.0.1:9200</argument>
60+
<argument key="index">monolog</argument>
61+
<argument key="client"/>
62+
<argument key="level" type="constant">Monolog\Logger::DEBUG</argument>
63+
<argument key="bubble">true</argument>
64+
</service>
4765
</services>
4866
</container>
4967
5068
.. code-block:: php
5169
5270
// config/services.php
71+
use Monolog\Logger;
5372
use Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler;
5473
5574
$container->register(ElasticsearchLogstashHandler::class);
5675
76+
// optionally, configure the handler using the constructor arguments (shown values are default)
77+
$container->register(ElasticsearchLogstashHandler::class)
78+
->setArguments(
79+
'$endpoint' => "http://127.0.0.1:9200",
80+
'$index' => "monolog",
81+
'$client' => null,
82+
'$level' => Logger::DEBUG,
83+
'$bubble' => true,
84+
)
85+
;
86+
5787
Then reference it in the Monolog configuration:
5888

5989
.. configuration-block::

0 commit comments

Comments
 (0)