Laravel log with sapi suffix I have old app that has this code
$app->configureMonologUsing(function(Monolog\Logger $monolog) {
$filename = storage_path('logs/laravel-'.php_sapi_name().'.log');
$handler = new Monolog\Handler\RotatingFileHandler($filename);
$monolog->pushHandler($handler);
});
So if I use Log::info("hello"); and run it from cli it will write into file 2024-01-12-laravel-cli.log, if from web to 2024-01-12-laravel-web.log or soemthing like that.
How to do this in new laravel 10?
@restart93 Doesn't this alternative way work for you?
Add a custom channel in config/logging.php:
'channels' => [
'custom' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel-'.php_sapi_name().'.log'),
'level' => 'debug',
],
],
And use LOG_CHANNEL=custom in your .env
Please sign in or create an account to participate in this conversation.