我在这里遇到同样的问题:
Write info message in app.log file using yii2
但是该主题没有解决方案。 Apache用户具有对logs文件夹的写许可权。我不知道为什么记录不起作用。
有任何评论吗?
这是config / main.php文件中的内容:
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
[
'class' => 'yii\log\FileTarget',
'levels' => ['info'],
'categories' => ['records'],
'logFile' => '@app/runtime/logs/records.log',
'maxFileSize' => 1024 * 2,
'maxLogFiles' => 20,
],
],
],
以及我用来写入日志文件的内容:
Yii::info('Sample text.', 'records');