Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Tracking bugs and errors in web applications

Sunday, May 21st, 2017 by Servage

bug-errorsBug tracking just got easier! What could be worse than losing a customer or a regular visitor due to some unknown error that a website can’t handle? On some websites, customers can provide feedback and tell what happened if they land on an error page. Many visitors don’t spend the time to fill out such forms so developers never get to know what really happened. This time we will look into ways that automatically report errors and collect information related to the issue when something unexpected happens.

Introducing Sentry

Sentry is an error tracking service that sends errors from your application to their service where you can view and inspect them using their dashboard. There is a free plan available that allows you to capture up to 10.000 error events every month, which should be enough for most small to medium websites.

Sentry works by hooking into your application and detecting whenever an error occurs. Most frameworks have functions that are run when an unhandled exception is generated. At this point, the framework can send the error to Sentry so that you can view its details using the Sentry dashboard.

Setting up Sentry

Sentry supports a large variety of languages and frameworks. In this example we will be integrating it with the popular Laravel PHP framework.

The first step is to install the required Sentry Laravel package using Composer: “composer require sentry/sentry-laravel”. Once this is done, you have to add the new service provider to the providers array of config/app.php: Sentry\SentryLaravel\SentryLaravelServiceProvider::class. You should also add an alias to the aliases array in the same file: ‘Sentry’ => Sentry\SentryLaravel\SentryFacade::class.

We are already halfway done! The second-last step is to open your App/Exceptions/Handler.php and add this to the first line of the report() function: app(‘sentry’)->captureException($e).

The last step is to set up the configuration files for Sentry. You can generate the files using “php artisan vendor:publish –provider=’Sentry\SentryLaravel\SentryLaravelServiceProvider’”. You should now check the config/sentry.php file and set your Sentry API key in your .env file. You can get this in the settings area of your Sentry account. To do this, you have to sign up for a free account at

You should now be able to see any errors of your application in the dashboard of your Sentry account. You can see the type of the error that occurred, a full stack trace, information about the client’s web browser and much more.

If Sentry is not available for your project or for some other reason you would prefer another approach, have a look at Bugsnag at It also comes with a free plan so you can test if it suits your needs better.

Tracking bugs and errors in web applications, 5.0 out of 5 based on 3 ratings
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet (leave a comment)

You are welcome to initiate a conversation about this blog entry.

Leave a comment

You must be logged in to post a comment.