From 6caa0b066d4415a3bb9db5ccd18a2954a09f8b16 Mon Sep 17 00:00:00 2001 From: Benjamin Brummer Date: Thu, 9 Oct 2025 12:46:51 +0200 Subject: [PATCH] Conditional/additional logging channel for docker deplyoment based on IS_DOCKER --- config/logging.php | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/config/logging.php b/config/logging.php index b9f74aa68b..3708651479 100644 --- a/config/logging.php +++ b/config/logging.php @@ -3,6 +3,7 @@ use Monolog\Handler\NullHandler; use Monolog\Handler\StreamHandler; use Monolog\Handler\SyslogUdpHandler; +use Monolog\Processor\PsrLogMessageProcessor; return [ @@ -32,7 +33,7 @@ return [ 'deprecations' => [ 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), - 'trace' => false, + 'trace' => env('LOG_DEPRECATIONS_TRACE', false), ], /* @@ -53,43 +54,64 @@ return [ 'channels' => [ 'invoiceninja' => [ + 'driver' => 'stack', + 'channels' => ['invoiceninja-single', env('IS_DOCKER', false) ? 'stderr' : 'null'], + 'ignore_exceptions' => false, + ], + + 'invoiceninja-single' => [ 'driver' => 'single', 'path' => storage_path('logs/invoiceninja.log'), 'level' => env('LOG_LEVEL', 'debug'), 'days' => 7, ], + 'invoiceninja-reminders' => [ + 'driver' => 'stack', + 'channels' => ['invoiceninja-reminders-single', env('IS_DOCKER', false) ? 'stderr' : 'null'], + 'ignore_exceptions' => false, + ], + + 'invoiceninja-reminders-single' => [ 'driver' => 'single', 'path' => storage_path('logs/invoiceninja-reminders.log'), 'level' => env('LOG_LEVEL', 'debug'), 'days' => 90, ], + + 'deprecations' => [ + 'driver' => 'stack', + 'channels' => array_merge(explode(',', (string) env('LOG_DEPRECATIONS', 'single')), [env('IS_DOCKER', false) ? 'stderr' : 'null']), + ], + 'stack' => [ 'driver' => 'stack', - 'channels' => ['single'], + 'channels' => array_merge(explode(',', (string) env('LOG_STACK', 'single')), [env('IS_DOCKER', false) ? 'stderr' : 'null']), 'ignore_exceptions' => false, - 'days' => 7, ], 'single' => [ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), + 'replace_placeholders' => true, ], 'daily' => [ 'driver' => 'daily', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), - 'days' => 14, + 'days' => env('LOG_DAILY_DAYS', 14), + 'replace_placeholders' => true, ], 'slack' => [ 'driver' => 'slack', 'url' => env('LOG_SLACK_WEBHOOK_URL'), - 'username' => 'Laravel Log', - 'emoji' => ':boom:', + 'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'), + 'emoji' => env('LOG_SLACK_EMOJI', ':boom:'), 'level' => env('LOG_LEVEL', 'critical'), + 'replace_placeholders' => true, ], 'papertrail' => [ @@ -101,26 +123,31 @@ return [ 'port' => env('PAPERTRAIL_PORT'), 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), ], + 'processors' => [PsrLogMessageProcessor::class], ], 'stderr' => [ 'driver' => 'monolog', 'level' => env('LOG_LEVEL', 'debug'), 'handler' => StreamHandler::class, - 'formatter' => env('LOG_STDERR_FORMATTER'), - 'with' => [ + 'handler_with' => [ 'stream' => 'php://stderr', ], + 'formatter' => env('LOG_STDERR_FORMATTER'), + 'processors' => [PsrLogMessageProcessor::class], ], 'syslog' => [ 'driver' => 'syslog', 'level' => env('LOG_LEVEL', 'debug'), + 'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER), + 'replace_placeholders' => true, ], 'errorlog' => [ 'driver' => 'errorlog', 'level' => env('LOG_LEVEL', 'debug'), + 'replace_placeholders' => true, ], 'null' => [