Back to Blog Home

Logging Laravel Errors with Sentry

David Cramer image

David Cramer -

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 monitoring (via Monolog) as it ensures proper stack traces, minimal configuration, and expanded error monitoring features (such as application detection).

Getting Started with Laravel

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.

Share

Share on Twitter
Share on Bluesky
Share on HackerNews
Share on LinkedIn

Published

Sentry Sign Up CTA

Code breaks, fix it faster

Sign up for Sentry and monitor your application in minutes.

Try Sentry Free

Topics

SDK Updates

New product releases and exclusive demos

Listen to the Syntax Podcast

Of course we sponsor a developer podcast. Check it out on your favorite listening platform.

Listen To Syntax
© 2024 • Sentry is a registered Trademark of Functional Software, Inc.