Symfony5 中的日志弃用

时间:2021-06-14 09:21:19

标签: symfony5 monolog

我意识到,我的弃用不再显示。现在我尝试通过 monolog 来记录它们,所以希望当我运行我的测试时,弃用会记录在一个特殊的日志中。我使用 symfony 5.3

这是我的测试 Monolog 配置:

monolog:
    handlers:
        frontend:
            type: rotating_file
            path: "%kernel.logs_dir%/%kernel.environment%.frontend.log"
            level: debug
            channels: [ "frontend" ]
            max_files: 3
        deprecation:
            type: rotating_file
            path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log"
        deprecation_filter:
            type: filter
            handler: deprecation
            level: info
            channels: [ "php" ]
        main:
            type: rotating_file
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: info
            channels: [ "!event", "!frontend", "!deprecation"  ]
            max_files: 3
        console:
            type: console
            process_psr_3_messages: false
            channels: [ "!event", "!doctrine", "!console", "!frontend", !deprecation" ]

我在轮换测试日志中收到一般消息,但没有创建弃用日志文件。

我的配置有什么问题?

下次尝试:

monolog:
    handlers:
#        frontend:
#            type: rotating_file
#            path: "%kernel.logs_dir%/%kernel.environment%.log"
#            level: debug
#            channels: [ frontend ]
#            max_files: 3
        main:
            type: rotating_file
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: info
            channels: [ "!event", "!frontend", "!deprecations" ]
            max_files: 3
        console:
            type: console
            process_psr_3_messages: false
            channels: [ "!event", "!doctrine", "!console", "!frontend", "!deprecations" ]

还有一个额外的文件 deprecations.yaml:

monolog:
    channels: [deprecation]
    handlers:
        deprecation:
            type: rotating_file
            channels: [deprecation]
            path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log"

现在我将弃用日志记录到一个额外的弃用日志文件中(很好!),但它们还会向我的普通日志文件发送垃圾邮件!

仅在弃用日志中获得弃用的正确配置是什么?

0 个答案:

没有答案
相关问题