Symfony 3.4每日记录器

时间:2018-01-22 15:03:39

标签: symfony logging monolog

如何配置monolog,将记录器保存在"每日日志"中。现在它根据环境保存。如何在路径中添加日期?

monolog:
handlers:
    main:
        type:   stream
        path:   "%kernel.logs_dir%/%kernel.environment%.log"

1 个答案:

答案 0 :(得分:2)

正如in the doc所述,使用type: rotating_file代替stream,如果您不想用尽空间,请添加max_files

monolog:
handlers:
    main:
        type:   rotating_file
        path:   "%kernel.logs_dir%/%kernel.environment%.log"
        # max number of log files to keep
        # defaults to zero, which means infinite files
        max_files: 10