2017 © Pedro Peláez
 

library laravel-graylog2

Log your Laravel application errors to Graylog2

image

swisnl/laravel-graylog2

Log your Laravel application errors to Graylog2

  • Wednesday, July 25, 2018
  • by swisnl
  • Repository
  • 5 Watchers
  • 14 Stars
  • 4,746 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 2 Open issues
  • 13 Versions
  • 58 % Grown

The README.md

Graylog2 Logging for Laravel 5.x

License Build Status Made by SWIS, (*1)

🚨 THIS PACKAGE HAS BEEN ABANDONED 🚨, (*2)

We don't use this package anymore in our own projects and cannot justify the time needed to maintain it anymore. That's why we have chosen to abandon it. Feel free to fork our code and maintain your own copy or use one of the many alternatives., (*3)

Installation

  1. Run composer require for this package: composer require swisnl/laravel-graylog2
  2. Add the service provider to app.php if you don't like auto discovery: Swis\Graylog2\Graylog2ServiceProvider
  3. Run php artisan vendor:publish to publish the config file to ./config/graylog2.php.
  4. Configure it to your liking
  5. Done!

Logging exceptions

The default settings enable logging of exceptions. It will add the HTTP request to the GELF message, but it will not add POST values. Check the graylog2.log-requests config to enable or disable this behavior., (*4)

Minimum log level

You can adjust the minimum log level by changing the value log_levelin configuration., (*5)

Message Processors

Processors add extra functionality to the handler. You can register processors by modifying the AppServiceProvider:, (*6)

public function register()
{
    //...
    Graylog2::registerProcessor(new \Swis\Graylog2\Processor\ExceptionProcessor());
    Graylog2::registerProcessor(new \Swis\Graylog2\Processor\RequestProcessor());
    Graylog2::registerProcessor(new MyCustomProcessor());
    //...
}

The following processors are available by default:, (*7)

ExceptionProcessor, (*8)

Adds exception data to the message if there is any., (*9)

RequestProcessor, (*10)

Adds the current Laravel Request to the message. It adds the url, method and ip by default., (*11)

Custom processors

You can define a custom processor by implementing Swis\Graylog2\Processor\ProcessorInterface. The result should look something like this:, (*12)

<?php

namespace App\Processors;

use Auth;
use Swis\Graylog2\Processor\ProcessorInterface;

class MyCustomProcessor implements ProcessorInterface
{
    public function process($message, $exception, $context)
    {
        $message->setAdditional('domain', config('app.url'));

        if (Auth::user()) {
            $message->setAdditional('user_id', Auth::id());
        }

        return $message;
    }
}

Don't report exceptions

In app/Exceptions/Handler.php you can define the $dontReport array with Exception classes that won't be reported to the logger. For example, you can blacklist the \Illuminate\Database\Eloquent\ModelNotFoundException. Check the Laravel Documentation about errors for more information., (*13)

Logging arbitrary data

You can instantiate the Graylog2 class to send additional GELF messages:, (*14)

// Send default log message
Graylog2::log('emergency', 'Dear Sir/Madam, Fire! Fire! Help me!. 123 Cavendon Road. Looking forward to hearing from you. Yours truly, Maurice Moss.', ['facility' => 'ICT']);

// Send custom GELF Message
$message = new \Gelf\Message();
$message->setLevel('emergency');
$message->setShortMessage('Fire! Fire! Help me!');
$message->setFullMessage('Dear Sir/Madam, Fire! Fire! Help me!. 123 Cavendon Road. Looking forward to hearing from you. Yours truly, Maurice Moss.');
$message->setFacility('ICT');
$message->setAdditional('employee', 'Maurice Moss');
Graylog2::logMessage($message);

Troubleshooting

Long messages (or exceptions) won't show up in Graylog2

You might need to increase the size of the UDP chunks in the UDP Transport (see the config file). Otherwise, you can send packets in TCP mode., (*15)

The Versions

25/07 2018

dev-master

9999999-dev

Log your Laravel application errors to Graylog2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel logging graylog

25/07 2018

0.6.4

0.6.4.0

Log your Laravel application errors to Graylog2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel logging graylog

25/07 2018

dev-develop

dev-develop

Log your Laravel application errors to Graylog2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel logging graylog

19/06 2018

0.6.3

0.6.3.0

Log your Laravel application errors to Graylog2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel logging graylog

19/06 2018

0.6.2

0.6.2.0

Log your Laravel application errors to Graylog2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel logging graylog

01/06 2018

0.6.1

0.6.1.0

Log your Laravel application errors to Graylog2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel logging graylog

01/06 2018

0.6.0

0.6.0.0

Log your Laravel application errors to Graylog2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel logging graylog

24/01 2018

0.5.0

0.5.0.0

Log your Laravel application errors to Graylog2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel logging graylog

14/12 2017

0.4.0

0.4.0.0

Log your Laravel application errors to Graylog2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel logging graylog

29/09 2017

0.3.0

0.3.0.0

Log your Laravel application errors to Graylog2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel logging graylog

29/09 2017

dev-facades-and-config

dev-facades-and-config

Log your Laravel application errors to Graylog2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel logging graylog

07/09 2017

0.2.0

0.2.0.0

Log your Laravel application errors to Graylog2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel logging graylog

05/09 2017

0.1.0

0.1.0.0

Log your Laravel application errors to Graylog2

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel logging graylog