Log rotating with Monolog in Symfony2 Log rotating with Monolog in Symfony2 symfony symfony

Log rotating with Monolog in Symfony2


On linux, you can use logrotate (I don't know if exists other solutions on windows or macos)

In /etc/logrotate.d/ create a file (eg. sf2_myapp) and add this content :

/path/to/your/symfony_app/app/logs/prod.log {        daily        missingok        rotate 14        compress}

You should look for logrotate on Google for more infos


There is a logger called rotating_file.
Here is a sample configuration:

monolog:    handlers:        main:            type:  rotating_file            path:  %kernel.logs_dir%/%kernel.environment%.log            level: debug