At Agira, Technology Simplified, Innovation Delivered, and Empowering Business is what we are passionate about. We always strive to build solutions that boost your productivity.

, ,

Automated Laravel Error Logging and Monitoring

  • By Vignesh Thandapani
  • October 19, 2018
  • 773 Views

Laravel has got tremendous growth & improved a lot in recent years and our interest in exploring those features of Laravel has never got reduced a bit. Similarly, while exploring the significant features of laravel, we ought to work one of the frequently faced issue in Laravel. One of our client requested to explore the possibility of implementing automated Laravel error logging and monitoring features so we got to resolve with automated laravel error logging with the fine & stress free tool and the result was excellent. So am pretty sure that its gonna be the most needed & helpful feature you might need.
Before everything, let me give you the quick view what is this concept about, These error logging and monitoring tool in Laravel ideally introduced by Rollbar but Rollbar also supports multiple technologies other than Laravel. Here we’re focusing on Laravel, these automated error log and monitoring tool for Laravel will greatly help us to log & monitor all the errors of the web site that are faced by the end users. Parallely, this tool will also help us to analyze the whole history of error logging, like when its happened, the reason behind the issues and what can be everything will be addressed so it will be easy for us to handle the & solve the issues then & there. Alongside, this can greatly help us to enhance the user experience of the site.

Requirements:

 

  1. Need to create an account in RollBar
  2. Laravel 5.6 or above

 

Why Rollbar?

Well, here is the quick comparison of the application with Rollbar and without Rollbar to decide why we should move on to Rollbar.

WITHOUT ROLLBAR WITH ROLLBAR
Errors will be get lost in the sea of logs Errors are automatically grouped, and their history can be tracked
Getting from an error to the code will take much time Full stack monitoring with visibility of errors on both web and server side
Manually tracking down must be needed to track the changes during production Source code integration to see the root cause code in a single click
No visibility or tracking record of how many users and which customers got affected Can instantly see the new errors for each deploy, along with the code changes made
Difficult to debug or reproduce problems without context You can prioritize errors for fixing
Debugs faster with local variables and request parameters for each error


How To Integrate the Rollbar with laravel

 

Follow these below steps to integrate the Rollbar with laravel applications, If you had already worked with Laravel then you don’t have to worry about the installation process just jump straight to the steps and incase if you are new to laravel then no worries just refer this guide to install and configure Laravel http://test.agiratech.com/install-laravel-5-1-and-do-simple-authentication/

1. First we need an account in Rollbar if not, use this link https://rollbar.com to signup and remember while registering itself you will have an option to a create project.
2. While creating projects you will also have an option to select technology so choose based on the selected technology your installation steps will be followed,
3. Now, open the command prompt and change the your project path like this cd your_project_path”
4. Then run the below command to install the Rollbar SDK into laravel “

composer require rollbar/rollbar-laravel

 
6. Copy the project access token which you can get it from the Rollbar project dashboard.
7. Now add your project access token into .env file which you can find it inside of the laravel project.

 ROLLBAR_TOKEN=[your Rollbar project access token]

 
8. Then add the service provider to the ‘providers’ array which you can find it in config/app.php

 Rollbar\Laravel\RollbarServiceProvider::class,

 
9. Finally, add the below code snippet into config/logging.php under the channel key:

       'rollbar' => [
           'driver' => 'monolog',
           'handler' => \Rollbar\Laravel\MonologHandler::class,
           'access_token' => env('ROLLBAR_TOKEN'),
           'level' => 'error',
       ]

 
10. Add the following code to send a test message and with that we could confirm whether the Rollbar is properly configured or not:

  \Log::debug('Test debug message');

 
Once you done with the installation then all the logs will be automatically stored in Rollbar. Alongside, if you need to know more about the additional setups instruction then refer this link https://docs.rollbar.com/docs/laravel

That’s it guys! all set to rock! Now you will be able to check and monitor all the logs of your Laravel application through Rollbar. With rollbar, improve the user experience fixing up the issues then & there.

 

Best To Read: Best Laravel Security Practices You Must Try It Out!

Liked it? Similarly find more informative blogs on our largest blog repository, Stay updated with latest topics & tricks and don’t forget to subscribe us to get the latest updates from diverse technologies. Besides all, post us your valuable thoughts in the comment section. For any queries reach us via info@agiratech.com.

Vignesh Thandapani

An enthusiastic Tech Lead with 6 plus years of experience in Web development arena. Owns legitimate experience in CorePHP, Laravel, Symfony, CakePHP, Wordpress, Joomla. Behalf, a young Aspiring "Travel admirer" craves to live with Nature.