symfony / monolog-bundle

Symfony Monolog Bundle
symfony.com
MIT License
2.9k stars 232 forks source link

Failed when service not available #497

Open dykyi-roman opened 1 week ago

dykyi-roman commented 1 week ago

Case: I want to redirect logs to another source (file) if the main source (logstash) is not available. Application doesn't work if logstash crashes. Applications should not depend on Infrastructure.

I try to use the next monolog config:

    monolog:
        handlers:
            main:
                type: fingers_crossed
                action_level: error
                handler: grouped
                excluded_http_codes: [ 404, 405 ]
            grouped:
                type: group
                members: [ logstash, file ]
            logstash:
                type: socket
                connection_string: 'tcp://logstash:5000'
                timeout: 1
                level: debug
                formatter: monolog.formatter.logstash
                persistent: false
                connection_timeout: 1
            file:
                type: rotating_file
                path: "%kernel.logs_dir%/%kernel.environment%.log"
                level: debug
                max_files: 10
                formatter: monolog.formatter.json
                bubble: true

Error: Failed connecting to tcp://logstash:5000 (0: php_network_getaddresses: getaddrinfo for logstash failed: Name or service not known)