Write info message in app.log file using yii2

泪湿孤枕 提交于 2019-12-24 08:10:55

问题


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,

来源:https://stackoverflow.com/questions/41692592/write-info-message-in-app-log-file-using-yii2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!