Sentry (Raven) error monitoring for Laravel 4 & 5 with send in background using queues
Sentry (Raven) error monitoring for Laravel 5 with send in background using queues. This will add a listener to Laravel's existing log system. It makes use to Laravel's queues to push messages into the background without slowing down the application.
Add the package to your composer.json
and run composer update
.
{
"require": {
"clowdy/laravel-raven": "2.*"
}
}
Add the service provider in config/app.php
:
'Clowdy\Raven\RavenServiceProvider',
Register the Raven alias:
'Raven' => 'Clowdy\Raven\Facades\Raven',
You also need to modify app\Exceptions\Hander.php
to extend Clowdy\Raven\Handler
instead of Illuminate\Foundation\Exceptions\Handler
as below:
<?php namespace app\Exceptions;
use Exception;
// use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Clowdy\Raven\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
Checkout the 1.0 branch
Publish the included configuration file:
$ php artisan vendor:publish --provider="clowdy\laravel-raven\RavenServiceProvider" --tag="config"
Change the Sentry DSN by using the RAVEN_DSN
env variable or changing the config file:
RAVEN_DSN=your-raven-dsn
This library uses the queue system, make sure your config/queue.php
file is configured correctly. You can also specify the connection and the queue to use in the raven config. Connection must exist in config/queue.php
and a custom queue can be defined. These can be set using the RAVEN_QUEUE_CONNECTION
for connection and RAVEN_QUEUE_QUEUE
for the custom queue.
RAVEN_QUEUE_CONNECTION=beanstalkd
RAVEN_QUEUE_QUEUE=error
To monitor exceptions, simply use the Log
facade:
Log::error($exception);
You can change the logs used by changing the log level in the config by modifying the env var.
RAVEN_LEVEL=error
You can pass additional information as context like this:
Log::error('Oops, Something went wrong', [
'user' => ['name' => $user->name, 'email' => $user->email]
]);
This package was inspired rcrowe/Raven.