Migrating from 5.5.* to 5.6.3 has resulted in logging not reading my configuration files. It is currently only logging to storage/logs/laravel.log - not even lumen.log.
I was previously using configureMonologUsing() and have attempted to convert everything into config/logging.php. That didn't work, so I took the base Lumen logging config and it still would not work. Note that this is running in a Docker container (which shouldn't matter). The container is why I have extra logging setup - I was logging to stderr in order to utilize the docker logs command.
Here's my current config/logging.php:
return [
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => [
'burp'
]
],
'burp' => [
'driver' => 'single',
'path' => '/tmp/x.txt',
'level' => 'debug'
]/*,
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/lumen.log'),
'level' => 'debug',
'days' => 7
],
'syslog' => [
'driver' => 'syslog',
'level' => 'debug'
],
'errorlog' => [
'driver' => 'errorlog',
'level' => 'debug'
]*/
]
];
I don't get anything in /tmp/x.txt. I've tried adding $app->configure('logging'); to my bootstrap/app.php to no avail.
Just for testing I set this in my .env file:
LOG_CHANNEL=burp
I was having the same issue, can you try using the logging.php below?
<?php
use Monolog\Handler\StreamHandler;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/lumen.log'),
'level' => 'debug',
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/lumen.log'),
'level' => 'debug',
'days' => 7,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Lumen Log',
'emoji' => ':boom:',
'level' => 'critical',
],
'stderr' => [
'driver' => 'monolog',
'handler' => StreamHandler::class,
'with' => [
'stream' => 'php://stderr',
],
],
'syslog' => [
'driver' => 'syslog',
'level' => 'debug',
],
'errorlog' => [
'driver' => 'errorlog',
'level' => 'debug',
],
],
];
Note in your logging.php the default key is missing as well as the stderr one in the channels array
Yeah, I think the _default_ key missing was my problem. This is now working.
Most helpful comment
I was having the same issue, can you try using the logging.php below?
Note in your logging.php the default key is missing as well as the stderr one in the channels array