monolog-bundle icon indicating copy to clipboard operation
monolog-bundle copied to clipboard

max_files configuration for rotating_file handler ignored

Open blundercon opened this issue 4 years ago • 4 comments

We have noticed an issue with the following configuration:

monolog:
    handlers:
        main:
            type: fingers_crossed
            action_level: error
            handler: nested
        nested:
            type: rotating_file
            path: '%kernel.logs_dir%/%kernel.environment%.log'
            level: debug
            max_files: 10
        console:
            type: console

The logs are rotated fine but older files are not cleaned up. In effect, it is like max_files is completely ignored.

Symfony Version: 3.4 Monolog Bundle Version: ^3.0.2

Please let me know whether this is expected or an issue.

blundercon avatar Oct 09 '20 06:10 blundercon

It looks to me as if the option is passed to the handler, see MonologExtension.php#L395-L401. Are you sure this is not an issue with the handler itself or your setup, e.g. due to file permissions? If it's an issue with the handler you should consider opening an issue with seldaek/monolog instead.

dbrumann avatar Oct 23 '20 13:10 dbrumann

It looks to me as if the option is passed to the handler, see MonologExtension.php#L395-L401. Are you sure this is not an issue with the handler itself or your setup, e.g. due to file permissions? If it's an issue with the handler you should consider opening an issue with seldaek/monolog instead.

I doubt it's a permission issue since new files are being created daily. Just to verify, what is the expected permission level ?

blundercon avatar Oct 23 '20 18:10 blundercon

Any updates here ?

blundercon avatar Nov 22 '20 11:11 blundercon

I have a Symfony 4.4-project which uses the rotating_file-handler for the dev environment and it works as expected, i.e. it keeps as many files as I specify in the config and does not touch files that were not created by it in the same folder, e.g. a separate error.log. There is not much else I can do, unless you can provide a demo-app which reproduces your problem.

dbrumann avatar Nov 24 '20 09:11 dbrumann