繁体   English   中英

Symfony2禁用测试环境中的日志

[英]Symfony2 disable logs in test environment

如何在测试环境中禁用任何日志? 问题纠正独白建立相关config_test.yml文件,从继承config_dev.yml ,其中配置是这样的:

monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      grouped_main
        streamed_main:
            type:   stream
            path:   "%kernel.logs_dir%/%kernel.environment%.log"
            level:  debug
        grouped_main:
            type:    group
            members: [streamed_main]
        console:
            type:   console
            bubble: false
            verbosity_levels:
                VERBOSITY_VERBOSE: INFO
                VERBOSITY_VERY_VERBOSE: DEBUG
            channels: ["!doctrine"]
        console_very_verbose:
            type:   console
            bubble: false
            verbosity_levels:
                VERBOSITY_VERBOSE: NOTICE
                VERBOSITY_VERY_VERBOSE: NOTICE
                VERBOSITY_DEBUG: DEBUG
            channels: ["doctrine"]

您可以使用继承来更改处理程序的类型,甚至更改级别:

config_test.yml

monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      grouped_main
        streamed_main:
            type:   fingers_crossed
            path:   "%kernel.logs_dir%/%kernel.environment%.log"
            level:  error

您还可以更改为bubble: false

也许你也可以重新考虑不使用日志,你可以将它保存在syslog和其他后端,这对你来说更方便!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM