ErrorLogger
  • ErrorLogger
  • Integrations
    • Frontend
    • Backend
      • ASP .NET Core
      • NodeJS
      • Laravel
  • Change Log
Powered by GitBook
On this page
  • Installation
  • ENV Configuration
  • Frontend
  • Testing
  • Option 1:
  • Option 2:

Was this helpful?

  1. Integrations
  2. Backend

Laravel

Laravel 7.x package for logging errors

PreviousNodeJSNextChange Log

Last updated 4 years ago

Was this helpful?

Installation

You can install the package through Composer.

composer require cerealkiller/error-logger-laravel-sdk

Then publish the config and migration file of the package using artisan.

php artisan vendor:publish --provider="ErrorLogger\ErrorLoggerServiceProvider"

And adjust config file (config/errorlogger.php) with your desired settings.

Note: By default only local environments will report errors. To modify this edit your errorlogger configuration.

ENV Configuration

Application keys are generated at

All that is left to do is to define env configuration variable in .env

ERRORLOGGER_API_KEY=

ERRORLOGGER_API_KEY is key which authorizes your application to the API.

Next is to add the errorlogger driver to the logging.php file:

'channels' => [
    'errorlogger' => [
        'driver' => 'errorlogger',
    ],
],

After that you have configured the ErrorLogger channel you can add it to the stack section:

'channels' => [
    'stack' => [
        'driver' => 'stack',
        'channels' => ['single', 'errorlogger'],
    ],
],

Frontend

To catch frontend errors, add this include blade directive on top of the file where you want to log errors.

@include('errorlogger::js-errorlogger-client')

Testing

Now test to see if it works, you can do this in two ways.

Option 1:

Run this in your terminal:

php artisan errorlogger:test

Option 2:

Run this code in your application to see if the exception is received by ErrorLogger.

throw new \Exception('Testing my application!');

And you are good to go! Happy coding :)

https://error-logger.netlify.app/