Log rotating with Monolog in Symfony2

一世执手 提交于 2019-12-03 10:45:48

问题


I'd like to know if there's any possibility to configure Monolog in Symfony2 to create a new log file every day, for example : 2013-11-21-prod.log.


回答1:


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



回答2:


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



来源:https://stackoverflow.com/questions/20126530/log-rotating-with-monolog-in-symfony2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!