yaml/symfony2:覆盖配置

Sgo*_*kes 6 php yaml symfony monolog

我想在config_test.yml中覆盖config_dev.yml中的一些配置.所以,想象一下config_dev.yml中的以下部分:

monolog:
    handlers:
        main:
            type: stream
            path: %kernel.logs_dir%/%kernel.environment%.log
            level: debug
        firephp:
            type: firephp
            level: info
Run Code Online (Sandbox Code Playgroud)

在我的测试环境中,我根本不需要记录器.所以我试过了

monolog: ~
Run Code Online (Sandbox Code Playgroud)

没有效果.我也尝试过:

monolog:
    handlers:
        main: ~
        firephp: ~
Run Code Online (Sandbox Code Playgroud)

再没有任何影响.然后我测试了

monolog:
    handlers:
        main:
            type: ~
            path: ~
            level: ~
        firephp:
            type: ~
            level: ~
Run Code Online (Sandbox Code Playgroud)

我得到一个ErrorException Couldn't find constant Monolog\Logger::.如果有人能指出一种方法来覆盖monolog设置,我将非常感激.谢谢!

lis*_*nko 8

最好将处理程序定义为空数组:

monolog:
    handlers: []
Run Code Online (Sandbox Code Playgroud)

UPD1:有特殊类型的记录器:test和null,你可以使用它们:

monolog:
    handlers:
        test:
            type:  test
            level: debug
Run Code Online (Sandbox Code Playgroud)