Yii 3: Is runtime/logs the default location for application logs?

Hi everyone,

I’m working with Yii 3 and wanted to confirm the default logging behavior.

From what I understand, application logs are written to the runtime/logs directory by default. Is that the expected behavior in a standard Yii 3 application, or does it depend on the logger implementation (for example, Monolog) and its configuration?

If runtime/logs is not always the default, could someone explain:

  • What the default log location is in a standard Yii 3 setup.
  • Which configuration file or package controls the log file path.
  • Whether there are any recommended practices for changing the log location in production.

I’d appreciate any clarification or references to the official documentation.

Thank you!

The Yii3 web application template configuration only contains StreamTarget::class as the log target.
You can install the yiisoft/log-target-file package and then add FileTarget::class to the ‘targets’ array.
The ‘file’ => ‘@runtime/logs/app.log’ parameter is included by default in the yiisoft/log-target-file package.
To change the file parameter, add the following to config/common/params.php:

//config/common/params.php
return [
   // ...
    'yiisoft/log-target-file' => [
        'fileTarget' => [
            'file' => '@runtime/mylogs/app.log',
        ]
    ],
];