Search code examples
phpsymfonyyamlmonolog

yaml/symfony2: Override configurations


I wanto to override some configurations from config_dev.yml in my config_test.yml. So, imagine the following part in the config_dev.yml:

monolog:
    handlers:
        main:
            type: stream
            path: %kernel.logs_dir%/%kernel.environment%.log
            level: debug
        firephp:
            type: firephp
            level: info

In my test environment, I want no logger at all. So I tried

monolog: ~

with no effect. I also tried:

monolog:
    handlers:
        main: ~
        firephp: ~

again without any effect. Then I tested

monolog:
    handlers:
        main:
            type: ~
            path: ~
            level: ~
        firephp:
            type: ~
            level: ~

and I get a ErrorException Couldn't find constant Monolog\Logger::. If anybody could point out a way to override the monolog settings I would very much appreciate it. Thanks!


Solution

  • It's better to define handlers as empty array:

    monolog:
        handlers: []
    

    UPD1: There are special type of loggers: test and null, you can use them:

    monolog:
        handlers:
            test:
                type:  test
                level: debug