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!
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
Your config_dev.yml
looks something like this for monolog out of the box:
# config_dev.yml
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
nested:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
As you can see this defines the handlers main
and nested
where nested
is only used because it's referenced by main
.
config_dev.yml
is imported from config_test.yml
so
if you want to override the configuration for your test environment you need to override the main
handler in config_test.yml
:
# config_text.yml
monolog:
handlers:
main:
type: test
This will stop monolog from creating a log file.
Have you tried:
monolog:
handlers: ~
It should work (I think). Look here Without handlers, monolog is not load.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With