Yii log skip 404 errors

Maybe there is a solution to skip 404 exceptions? I'mean not store these messages in a log file?

2015/04/09 12:28:52 [error] [exception.CHttpException.404] exception 'CHttpException' with message '   "offer/downloadOffer".' in /var/www/yii/framework/web/CWebApplication.php:286 Stack trace: #0 /var/www/yii/framework/web/CWebApplication.php(141): CWebApplication->runController('offer/downloadO...') #1 /var/www/yii/framework/base/CApplication.php(184): CWebApplication->processRequest() #2 /var/www/LAP/www/index.php(16): CApplication->run() #3 {main} REQUEST_URI=/offer/downloadOffer 
+5
source share
3 answers

The decision excludes categories.

 array( 'class' => 'CFileLogRoute', 'categories' => '!exception.CHttpException.404' ), array( 'class' => 'CEmailLogRoute', 'categories' => '!exception.CHttpException.*' ), 
+8
source

For Yii 2.0, you can do your config / main.php as follows:

 return [ 'components' => [ 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], 'except' => ['yii\web\HttpException:404'], ], ], ], ], ]; 
+2
source

For Yii 1.1, the correct way to exclude a category is to use the except key. Priority ! in the category key according to the accepted answer will actually only lead to the corresponding categories starting with ! . Therefore, although it may work, you will really suppress all categories. See filterAllCategories() function of source code - no character handling ! , template only * : GitHub source .

I tried the approach !exception.CHttpException.404 in the accepted answer and thought that I solved the problem to hide 404 errors, but then I realized that after a lot of hair pulling this led to no logs being logged!

The correct syntax for ignoring a category is:

 array( 'class' => 'CFileLogRoute', 'except' => 'exception.CHttpException.404' ) 
0
source

All Articles