Search code examples
symfonyloggingsymfony4monolog

How I make log by day in Symfony


community. I need make logs files daily with Symfony4; or push a current date in a yml file. Specifically in monologo.yml.

 handlers:
    app:
        type: stream
        path: "%kernel.logs_dir%/system_compact_%kernel.environment%-***date***.log"
        channels: ["app"]

Thank a lot.


Solution

  • Use can use "rotating_file" log type:

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

    Look at this documentation page: https://symfony.com/doc/current/logging.html#how-to-rotate-your-log-files