Unable to use stack channel logging in Laravel

30 views Asked by At

I'm unable to use 'stack' channel logging, hoping you can help.

In my Laravel (9.x) project, I've setup a 'gelf' channel that logs to my Graylog. I want logs both in Graylog and in storage/logs/laravel.log

My config/logging.php:

'default' => 'stack',

'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['single', 'gelf'],
            'ignore_exceptions' => false,
        ],

        'single' => [
            'driver' => 'single',
            'path' => storage_path('logs/laravel.log'),
            'level' => env('LOG_LEVEL', 'debug'),
        ],

        'gelf' => [
            'driver' => 'custom',
            ...
        ]
]

In this configuration, I ONLY get log output in laravel.log. If I set channels.stack.channels to ['single'], I of course still get output to laravel.log. If I set channels.stack.channels to ['gelf'], nothing happens. If I change default to 'gelf', then I get Graylog logging, but of course, nothing in laravel.log.

What am I possibly missing? I don't see others on Google with this issue.


Troubleshooting attempts:
  • I've done php artisan config:cache on every change, so have ruled out caching issues.

  • As a temporary work-around, I've just set it to 'gelf' and registered a reportable in the App\Exceptions\Handler::register() method for the single channel:

public function register():void
{
    $this->reportable(function (Throwable $e) {
        Log::channel('single')->warning($e);
    });
}
0

There are 0 answers