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.

Upvotes: 5

Views: 3240

Answers (1)

G1.3
G1.3

Reputation: 1879

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

Upvotes: 6

Related Questions