How to disable any logs in test environment? Question related to correct monolog setup in config_test.yml
file, that inherited from config_dev.yml
, where config looks like this:
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"]
You can use the inheritance to change the type of the handler, and even the level:
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
You can also change to bubble: false
Maybe you can also reconsider no using logs, you can save it on syslog and other backends which can be more convenient to you!