Write info message in app.log file using yii2

2019-07-30 07:22发布

I want to write info message in app.log file for debugging. For that I am using that code in web.php file:-

      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,
                ],

            ],
     ] 

and in my controller file I am using that code :-

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

but no message is written in .log file.

Thank you,

0条回答
登录 后发表回答