Сконфигурировано логирование приложения

This commit is contained in:
ErickSkrauch 2016-09-09 00:39:00 +03:00
parent d2fd803b0d
commit dd2407e347
2 changed files with 29 additions and 0 deletions

View File

@ -3,6 +3,7 @@ namespace api\components;
use api\modules\authserver\exceptions\AuthserverException; use api\modules\authserver\exceptions\AuthserverException;
use api\modules\session\exceptions\SessionServerException; use api\modules\session\exceptions\SessionServerException;
use Yii;
class ErrorHandler extends \yii\web\ErrorHandler { class ErrorHandler extends \yii\web\ErrorHandler {
@ -17,4 +18,14 @@ class ErrorHandler extends \yii\web\ErrorHandler {
return parent::convertExceptionToArray($exception); return parent::convertExceptionToArray($exception);
} }
public function logException($exception) {
if ($exception instanceof AuthserverException) {
Yii::error($exception, AuthserverException::class . ':' . $exception->getName());
} elseif ($exception instanceof SessionServerException) {
Yii::error($exception, SessionServerException::class . ':' . $exception->getName());
} else {
parent::logException($exception);
}
}
} }

View File

@ -26,6 +26,24 @@ return [
[ [
'class' => \yii\log\FileTarget::class, 'class' => \yii\log\FileTarget::class,
'levels' => ['error', 'warning'], 'levels' => ['error', 'warning'],
'except' => [
'legacy-authserver',
'session',
'api\modules\session\exceptions\SessionServerException:*',
'api\modules\authserver\exceptions\AuthserverException:*',
],
],
[
'class' => \yii\log\FileTarget::class,
'levels' => ['error', 'info'],
'categories' => ['legacy-authserver'],
'logFile' => '@runtime/logs/authserver.log',
],
[
'class' => \yii\log\FileTarget::class,
'levels' => ['error', 'info'],
'categories' => ['session'],
'logFile' => '@runtime/logs/session.log',
], ],
], ],
], ],