使用yii2在app.log文件中写入信息消息

时间:2017-01-17 08:48:16

标签: yii2 yii2-basic-app

我想在app.log文件中写信息进行调试。为此,我在web.php文件中使用该代码: -

      log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],

                  [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['info'],
                    'categories' => ['orders'],
                    'logFile' => '@app/runtime/logs/requests.log',
                    'maxFileSize' => 1024 * 2,
                    'maxLogFiles' => 20,
                ],
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['info'],
                    'categories' => ['pushNotifications'],
                    'logFile' => '@app/runtime/logs/Orders/notification.log',
                    'maxFileSize' => 1024 * 2,
                    'maxLogFiles' => 50,
                ],

            ],
     ] 

在我的控制器文件中我正在使用该代码: -

   Yii::info($valuerendom, 'orders');

但没有在.log文件中写入消息。

谢谢,

0 个答案:

没有答案