If you have created a new Symfony project recently, you may have noticed a big
change in the development log file. In the past, even the simplest page load
generated tens of lines in the dev.log
file. In the latest Symfony versions,
by default only the important information is logged.
This image clearly shows the differences in the dev.log
file created by the
simple Welcome to Symfony page. In Symfony 2.7.7 it contained 63 lines, but in
the Symfony 2.7.9 version it only contains 3 lines:

Which Information is Missing?
Newer Symfony versions no longer log the information of the event
channel,
which produced messages like these:
1 2 3
event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure". [] []
event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". [] []
...
We did this by changing the default configuration of the Symfony Standard edition:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# app/config/config_dev.yml
# BEFORE
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
# AFTER
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: [!event]
The !
prefix tells Monolog to log all channels except event
. You can
exclude more channels (e.g. channels: [!event, !doctrine]
) and you can leave
it empty to start logging event messages again.
In addition, this change can be applied to all your existing Symfony applications,
regardless of the Symfony version they use. Just add channels: [!event]
to
your Monolog configuration in config_dev.yml
and say goodbye to those
annoying log messages.
Improving Your Logs
Monolog, the library used by Symfony to log contents through the MonologBundle, is still heavily underused by most Symfony developers. As this article shows, even a minor configuration change can have a positive impact in your development experience. Don't forget to check out the documentation to learn:
- How to log messages to different files, which is useful to store the messages from some channels in log files different than `dev.log` and `prod.log`.
- How to easily create new log channels, so you can process those messages differently or store them in separate files.
- How to inject a preconfigured logger into services so the generated messages are logged in the given channel.
After clicking on the screenshot to see a full size version on Flickr, Yahoo is prompting me to log in. Is the image set to private, or is this how Flickr works now?
@Kevin thanks for letting me know. It should be fixed by now.
Very nice change. So small with so great output. Thanks for constantly improving DX!
Really awesome! ^_^
Well, a way better :)
Finally, a good way to remove superflux logs
Good thing, those logs have always been totally useless.
Less is more! :)
Can we also remove this information from Debug toolbar ?
The events lines are not written in "dev.log" but still displayed in the "Debug" tab of "Log" Section in the Profiler.