问题描述
我想在我的 config_test.yml 中覆盖 config_dev.yml 中的一些配置.因此,想象一下 config_dev.yml 中的以下部分:
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: ~
没有效果.我也试过:
monolog:
handlers:
main: ~
firephp: ~
再次没有任何影响.然后我测试了
again without any effect. Then I tested
monolog:
handlers:
main:
type: ~
path: ~
level: ~
firephp:
type: ~
level: ~
并且我得到一个 ErrorException 无法找到常量 Monolog\Logger::
.如果有人能指出一种覆盖独白设置的方法,我将非常感激.谢谢!
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!
推荐答案
最好将处理程序定义为空数组:
It's better to define handlers as empty array:
monolog:
handlers: []
UPD1: 有特殊类型的记录器:test 和 null,你可以使用它们:
UPD1: There are special type of loggers: test and null, you can use them:
monolog:
handlers:
test:
type: test
level: debug
这篇关于yaml/symfony2:覆盖配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!