monolog:
    channels:
        - deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists

when@dev:
    monolog:
        handlers:
            main:
                type: stream
                path: "%kernel.logs_dir%/%kernel.environment%.log"
                level: debug
                channels: ["!event"]
            # uncomment to get logging in your browser
            # you may have to allow bigger header sizes in your Web server configuration
            #firephp:
            #    type: firephp
            #    level: info
            #chromephp:
            #    type: chromephp
            #    level: info
            console:
                type: console
                process_psr_3_messages: false
                channels: ["!event", "!doctrine", "!console"]

when@test:
    monolog:
        handlers:
            main:
                type: fingers_crossed
                action_level: error
                handler: nested
                excluded_http_codes: [404, 405]
                channels: ["!event"]
            nested:
                type: stream
                path: "%kernel.logs_dir%/%kernel.environment%.log"
                level: debug

when@prod:
    monolog:
        handlers:
            # Fingers crossed handler: only triggers on error+
            main:
                type: fingers_crossed
                action_level: error
                handler: grouped
                excluded_http_codes: [404, 405]
                buffer_size: 50

            # Group handler lets you send logs both to rotating file (persisted errors)
            # and to stderr (live stream)
            grouped:
                type: group
                members: [file, stderr]

            # Rotating file: keeps max 2 days of logs, only error+
            file:
                type: rotating_file
                path: "%kernel.logs_dir%/%kernel.environment%.log"
                max_files: 2
                level: error

            # Live stream: all levels go here, no memory issues since it's stdout/stderr
            stderr:
                type: stream
                path: php://stderr
                level: debug
                formatter: monolog.formatter.json

            # Console handler for Symfony CLI commands
            console:
                type: console
                process_psr_3_messages: false
                channels: ["!event", "!doctrine"]

            # Deprecations (optional, still go to stderr)
            deprecation:
                type: stream
                channels: [deprecation]
                path: php://stderr
                formatter: monolog.formatter.json