카테고리 없음

[yii2] yii2에서 작동하지 않는 로그

필살기쓰세요 2021. 1. 14. 18:42

당신은 this.Use 시도 범주를 . 예를 들어 아래와 같이

            'targets' => [
           [
                           'class' => 'yii\log\FileTarget',
                                           'levels' => ['error'],
                                                            'categories' => ['test1'],
                                                                            'logFile' => '@app/Test/test1.log',
                                                                            
                                                                            
                                                                                        ],
                                                                                        

컨트롤러 액션에서 아래 하나를 사용하십시오

 public function actionIndex(){    
   Yii::error('Test index action', $category = 'test1');   }
   
-------------------

콘솔 구성에서 flushInterval둘 모두 exportInterval를 1로 설정하십시오.

return [
    'bootstrap' => ['log'],
        'components' => [
                'log' => [
                            'targets' => [
                                            [
                                                                'class' => 'yii\log\FileTarget',
                                                                                    'exportInterval' => 1,
                                                                                                    ],
                                                                                                                ],
                                                                                                                            'flushInterval' => 1,
                                                                                                                                    ],
                                                                                                                                        ],
                                                                                                                                        ];
                                                                                                                                        

각 로그 메시지가 로그에 즉시 표시되도록합니다.



출처
https://stackoverflow.com/questions/39915880