Share on Twitter
Share on Facebook
Share on HackerNews

Logging Laravel Errors with Sentry

Today we’re announcing native integration with Laravel through our new sentry-laravel package. This is a drastic improvement over our previous support for Laravel error tracking (via Monolog) as it ensures proper stack traces, minimal configuration, and expanded error monitoring features (such as application detection).

Getting Started

We’ve made it even easier to get started debugging Laravel on Sentry.

Install the sentry/sentry-laravel package:

$ composer require sentry/sentry-laravel

Add the Sentry service provider and facade in config/app.php:

'providers' => array(
    // ...
    Sentry\SentryLaravel\SentryLaravelServiceProvider::class,
)

'aliases' => array(
    // ...
    'Sentry' => Sentry\SentryLaravel\SentryFacade::class,
)

Add Sentry reporting to App/Exceptions/Handler.php:

public function report(Exception $e)
{
    app('sentry')->captureException($e);
    parent::report($e);
}

Create the Sentry configuration file (config/sentry.php):

$ php artisan vendor:publish --provider="Sentry\SentryLaravel\SentryLaravelServiceProvider"

From here, just toss the SENTRY_DSN in your .env file, or configure things via the config/sentry.php configuration.

Learn More

Take a look at the sentry-laravel project on GitHub to learn more about how things are implemented, as well as additional details on using it with Sentry.

Your code is broken. Let's Fix it.
Get Started

More from the Sentry blog

ChangelogDashboardsDiscoverDogfooding ChroniclesEcosystemError MonitoringEventsGuest PostsMoonlightingOpen SourcePerformance MonitoringRelease HealthSDK UpdatesSentry

Do you like corporate newsletters?

Neither do we. Sign up anyway.

© 2022 • Sentry is a registered Trademark
of Functional Software, Inc.