I'm trying to stream logs from a symfony 2 app to a graylog 2 server using the gelf format.
My monolog configuration looks as follows:
monolog:
handlers:
# --- 8< ---
# ...
# --- >8 ---
graylog:
type: gelf
publisher:
hostname: my-graylog-server.com
port: 12201
level: debug
formatter: app.gelf_formatter
When the graylog server is not available, I get (understandably) a connection refused error
[2017-07-28 16:03:25] app.ERROR: Failed to write to socket: fwrite(): send of 153 bytes failed with errno=111 Connection refused (8) [] []
which results in an internal server error (500 response code to the request causing the log).
(See also this question: Prevent Internal Server Error with Symfony 2 / Monolog on failed gelf connection)
gelf-php provides an IngoreErrorTransportLogger, which seems to be build for this exact purpose.
How can I configure this in Symfony's monolog config?