| Package Data | |
|---|---|
| Maintainer Username: | hedii | 
| Package Create Date: | 2016-09-09 | 
| Package Last Update: | 2025-03-22 | 
| Language: | PHP | 
| License: | MIT | 
| Last Refreshed: | 2025-10-28 03:02:17 | 
| Package Statistics | |
|---|---|
| Total Downloads: | 3,070,407 | 
| Monthly Downloads: | 70,619 | 
| Daily Downloads: | 3,206 | 
| Total Stars: | 132 | 
| Total Watchers: | 3 | 
| Total Forks: | 33 | 
| Total Open Issues: | 1 | 
A package to send gelf logs to a gelf compatible backend like graylog. It is a Laravel wrapper for bzikarsky/gelf-php package.
It uses the new Laravel custom log channel introduced in Laravel 5.6.
A gelf receiver like graylog2 must be configured to receive messages with a GELF UDP Input.
Install via composer
composer require hedii/laravel-gelf-logger
Edit config/logging.php to add the new gelf log channel.
return [
    'default' => env('LOG_CHANNEL', 'stack'),
    'channels' => [
        // You can use the gelf log channel with the stack log channel
        'stack' => [
            'driver' => 'stack',
            'channels' => ['daily', 'gelf'],
        ],
        // other log channels...
        'gelf' => [
            'driver' => 'custom',
            'via' => \Hedii\LaravelGelfLogger\GelfLoggerFactory::class,
            
            // This optional option determines the processors that should be
            // pushed to the handler. This option is useful to modify a field
            // in the log context (see NullStringProcessor), or to add extra
            // data. Each processor must be a callable or an object with an
            // __invoke method: see monolog documentation about processors.
            // Default is an empty array.
            'processors' => [
                \Hedii\LaravelGelfLogger\Processors\NullStringProcessor::class,
                \Foo\Bar\AnotherProcessor::class,
            ],
            // This optional option determines the minimum "level" a message
            // must be in order to be logged by the channel. Default is 'debug'
            'level' => 'debug',
            // This optional option determines the channel name sent with the
            // message in the 'facility' field. Default is equal to app.env
            // configuration value
            'name' => 'my-custom-name',
            // This optional option determines the host that will receive the
            // gelf log messages. Default is 127.0.0.1
            'host' => '127.0.0.1',
            // This optional option determines the port on which the gelf
            // receiver host is listening. Default is 12201
            'port' => 12201,
        ],
    ],
];
Once you have modified the Laravel logging configuration, you can use the gelf log channel as any Laravel log channel.
// Explicitly use the gelf channel
Log::channel('gelf')->debug($message, ['foo' => 'bar']);
Log::channel('gelf')->emergency($message, ['foo' => 'bar']);
// In case of a stack log channel containing the gelf log channel and stack
// configured as the default log channel
Log::notice($message, ['foo' => 'bar']);
// Using the logger helper
logger($message, $context);
composer test
laravel-gelf-logger is released under the MIT Licence. See the bundled LICENSE file for details.