Symfony2 monolog 配置:从调试消息中排除警告消息

Symfony2 monolog configuration: exclude warning messages from debug messages

我使用带有 monolog 的 Symfony 2.4 并且有 monolog 配置:

monolog:
    channels:               ["voter", "worker"]

    handlers:
        # 'critical' means HTTP 5XX responses.
        critical:
            type:           fingers_crossed
            action_level:   critical
            handler:        critical_group
        # 'error' means HTTP 4XX responses.
        error:
            type:           fingers_crossed
            action_level:   error
            handler:        error_stream
        debug:
            type:           fingers_crossed
            action_level:   debug
            handler:        debug_stream

        critical_group:
            type:           group
            members:        critical_stream

        critical_stream:
            type:           stream
            path:           %kernel.logs_dir%/%kernel.environment%_critical.log
            level:          critical
        error_stream:
            type:           stream
            path:           %kernel.logs_dir%/%kernel.environment%_error.log
            level:          error
        debug_stream:
            type:           stream
            path:           %kernel.logs_dir%/%kernel.environment%_warning.log
            level:          debug

我想从调试消息中排除警告消息。以及更清洁日志的错误消息中的警告和调试消息。有解决办法吗?

感谢您的任何建议!

您可以使用 filter 处理程序。

这里是一个基于您的配置的附加处理程序:

handlers:
    cleaned_debug:
        type: filter
        handler: debug
        accepted_levels: [DEBUG]