Laravel 5.6 and up

Rollbar SDK for Laravel 5.6 and up

Rollbar error monitoring integration for Laravel projects. This library adds a listener to Laravel's logging component. Laravel's session information will be sent into Rollbar, as well as some other helpful information such as environment, server, and session.

Note: this is documentation for projects based on Laravel 5.6 and up. If you are using Laravel 5.5 or lower, please follow instructions in Laravel 5.5 and lower.


  1. Install using composer:
composer require rollbar/rollbar-laravel
  1. Add Project Access Token post_server_item from → Settings → Project Access Tokens to .env:
  1. In config/logging.php, add the rollbar logging channel by adding the following under the channel key:
    'rollbar' => [
        'driver' => 'monolog',
        'handler' => \Rollbar\Laravel\MonologHandler::class,
        'access_token' => env('ROLLBAR_TOKEN'),
        'level' => 'debug',

To the above array you can add any other Rollbar configuration options you would normally use in the Rollbar PHP SDK.

For example, to associate an error with the user that is currently logged in, add the configuration option 'person_fn' and set it to 'Auth::user':

        'rollbar' => [
            // ... rest of current config
            'person_fn' => 'Auth::user',
            'capture_email' => true,            //optional
            'capture_username' => true     //optional
  1. Also in config/logging.php, either set rollbar as the default log channel by changing the value of the default key or add rollbar to the stack channel:
       'stack' => [
            'driver' => 'stack',
            'channels' => ['rollbar','single'],

Conditional loading

If you wish to load the SDK conditionally:

  1. Add the dont-discover clause in your app's composer.json:
    "extra": {
        "laravel": {
            "dont-discover": [
  1. Instead of adding the service provider in the providers array in config/app.php as displayed above, load it in your AppServiceProvider:
class AppServiceProvider extends ServiceProvider
    public function register()
        if ($this->app->environment(['staging', 'production'])) {


This package will automatically send to Rollbar every logged message whose level is at or higher than the 'level' you have configured.

Logging a Specific Message

You can log your own messages anywhere in your app. For example, to log a debug message:

\Log::debug('Here is some debug information');

Adding Context Information

You can pass user information as context like this:

\Log::error('Something went wrong', [
    'person' => ['id' => (string) 123, 'username' => 'John Doe', 'email' => '']

Or pass some extra information:

\Log::warning('Something went wrong', [
    'download_size' => 3432425235

Exception Logging

For Laravel 5.6, all errors which are normally handled by \App\Exceptions\Handler are going to be reported to Rollbar by default.


Setting up ROLLBAR_TOKEN in .env should be enough for basic configuration.

This package supports configuration through the services configuration file located in config/logging.php. All rollbar configuration variables will be directly passed to Rollbar:

    'rollbar' => [
        'driver' => 'monolog',
        'handler' => \Rollbar\Laravel\MonologHandler::class,
        'level' => 'info',
        'access_token' => env('ROLLBAR_TOKEN'),
        'environment' => 'special-environment'

The level setting defines the minimum log level at which log messages are sent to Rollbar. If not specified, the default is debug. For development, you could set this either to debug to send all log messages or to none to send no messages at all. For production, you could set this to error so that all info and debug messages are ignored.

Asynchronous Reporting

By default, payloads (batched or not) are sent as part of script execution. This is easy to configure but may negatively impact performance. With some additional setup, payloads can be written to a local relay file instead; that file will be consumed by rollbar-agent asynchronously. To turn this on, set the following config params:

$config = [
  // ... rest of current config
  'handler' => 'agent',
  'agent_log_location' => '/var/www'  // not including final slash. must be writeable by the user php runs as.

You'll also need to run the agent. See the rollbar-agent docs for setup instructions.

Centralized Log Aggregation with fluentd

If you have a fluentd instance running available you can forward payloads to this instance. To turn this on, set the following config params.

$config = [
  // ... rest of current config
  'handler' => 'fluent',
  'fluent_host' => 'localhost',  // localhost is the default setting but any other host IP or a unix socket is possible
  'fluent_port' => 24224, // 24224 is the default setting, please adapt it to your settings
  'fluent_tag' => 'rollbar', // rollbar is the default setting, you can adjust it to your needs

Also, you will have to install a suggested package fluent/logger.

Configuration Reference

See the Rollbar-PHP Configuration Reference

Help / Support

If you run into any issues, please email us at

For bug reports, please open an issue on GitHub.

For more information on rollbar-php, please see the docs here.