Parameter maxLogFiles (logfile rotation) has no effect

Hey,

I’m using Yii 2.0.32 and tried to set the application-log rotation using this setting:

            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                    'maxFileSize' => 10240, 
                    'maxLogFiles' => 6 
                ],

While the maxFileSize parameter works fine, the maxLogFiles parameter seams to be ignored. I tried maxLogFiles with the value 4, 6, 10 and 20, But the systems holds 5 files in each case. (I set the maxFileSize to 10k while testing the different variations of maxLogFiles)

Is there a reason why this happens and is there a way to debug this?

Thank you,
B.

No specific reason. Sounds like a bug. As for debugging it, it worth putting together a unit test with low limits and rotation turned on then validating number of files. When isolated, it will be easier to debug and fix it.

Still not fix?

I tried this with 2 and 6 maxLogFiles. Works as expected (Yii 2.0.46).

            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                    'maxFileSize' => 10, 
                    'maxLogFiles' => 6 
                ],

The maxFileSize must be specified in kB.

https://www.yiiframework.com/doc/api/2.0/yii-log-filetarget#$maxFileSize-detail