Simplified rollbar monitoring integration for Yii2 applications.
The preferred way to install this extension is through composer.
To install add
"eroteev/yii2-rollbar": "^1.0.0"
to the require
section of your composer.json
file.
- Add the component configuration in your global config file:
'bootstrap' => ['rollbar'],
'components' => [
'rollbar' => [
'class' => 'eroteev\rollbar\Rollbar',
'config' => [
'access_token' => 'POST_SERVER_ITEM_ACCESS_TOKEN',
]
],
],
- Add the web error handler configuration in your web config file:
'components' => [
'errorHandler' => [
'class' => 'eroteev\rollbar\error_handler\WebErrorHandler'
],
],
- Add the console error handler configuration in your console config file:
'components' => [
'errorHandler' => [
'class' => 'eroteev\rollbar\error_handler\ConsoleErrorHandler'
],
],
- Add log target in your global config file:
'log' => [
'targets' => [
[
'class' => 'eroteev\rollbar\log\RollbarTarget',
'levels' => ['error'], // Log levels you want to appear in Rollbar
'categories' => ['application'],
],
],
],
To ignore specific exceptions you can update the component configuration in your global config file:
'components' => [
'rollbar' => [
'class' => 'eroteev\rollbar\Rollbar',
'config' => [
// ...
'check_ignore' => function ($isUncaught, $toLog, $payload) {
return eroteev\rollbar\helpers\IgnoreExceptionHelper::checkIgnore($toLog, [
['yii\web\HttpException', 'statusCode' => [400, 404]],
['yii\db\Exception', 'getCode' => [2002]],
]
);
}
]
],
],