首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Symfony5中记录弃用日志

在Symfony5中记录弃用日志
EN

Stack Overflow用户
提问于 2021-06-14 17:21:19
回答 1查看 79关注 0票数 0

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

这是我的测试monolog配置:

代码语言:javascript
复制
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" ]

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

我的配置有什么问题?

下一次尝试:

代码语言:javascript
复制
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:

代码语言:javascript
复制
monolog:
    channels: [deprecation]
    handlers:
        deprecation:
            type: rotating_file
            channels: [deprecation]
            path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log"

现在我已经将弃用记录到了一个额外的弃用日志文件中(很好!),但它们还会给我的正常日志文件带来垃圾邮件!

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-22 02:47:26

看起来您应该将"!deprecations“替换为"!deprecation”。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67967712

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档