1

I've noticed that Craft 3 log files in storage/logs e.g. web-404s.log and web.log don't seem to have a max size or rotate like with Craft 2.

The web-404s.log file is nearly 10 megs for 1 site now.

Should the log files continually grow like this or is there just an issue with my setup?

Are there config settings to set the max log file size or disable certain logging that I'm missing?

Thanks

Janine
  • 241
  • 1
  • 8

1 Answers1

1

Craft goes with Yii 2's defaults in the FileTarget class, which is 10MB for a log file before rotating. https://www.yiiframework.com/doc/api/2.0/yii-log-filetarget#$maxFileSize-detail

You can overwrite that behavior from your config/app.php file by using something like:

'components' => [
        'log' => function() {
            $log = Craft::createObject([
                'class' => yii\log\Dispatcher::class,
                'targets' => [
                    [
                        'class' => craft\log\FileTarget::class,
                        'levels' => !YII_DEBUG ? yii\log\Logger::LEVEL_ERROR | yii\log\Logger::LEVEL_WARNING : yii\log\Logger::LEVEL_ERROR | yii\log\Logger::LEVEL_WARNING | yii\log\Logger::LEVEL_INFO | yii\log\Logger::LEVEL_TRACE | yii\log\Logger::LEVEL_PROFILE,
                        'maxFileSize' => 5120, // 5MB
                    ],
                ],
            ]);

            return $log;
        },
    ],
Brad Bell
  • 67,440
  • 6
  • 73
  • 143