【问题标题】:Symfony2 disable logs in test environmentSymfony2 在测试环境中禁用日志
【发布时间】:2016-03-04 04:34:05
【问题描述】:

如何禁用测试环境中的任何日志?与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"]

【问题讨论】:

    标签: php symfony logging config monolog


    【解决方案1】:

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

    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 和其他对你更方便的后端!

    【讨论】:

    • 你能解释一下这段代码在做什么吗?独白会节省更少的数据吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多