Conditional/additional logging channel for docker deplyoment based on IS_DOCKER

This commit is contained in:
Benjamin Brummer
2025-10-09 12:46:51 +02:00
parent 12f31054c9
commit 6caa0b066d

View File

@@ -3,6 +3,7 @@
use Monolog\Handler\NullHandler; use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler; use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler; use Monolog\Handler\SyslogUdpHandler;
use Monolog\Processor\PsrLogMessageProcessor;
return [ return [
@@ -32,7 +33,7 @@ return [
'deprecations' => [ 'deprecations' => [
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
'trace' => false, 'trace' => env('LOG_DEPRECATIONS_TRACE', false),
], ],
/* /*
@@ -53,43 +54,64 @@ return [
'channels' => [ 'channels' => [
'invoiceninja' => [ 'invoiceninja' => [
'driver' => 'stack',
'channels' => ['invoiceninja-single', env('IS_DOCKER', false) ? 'stderr' : 'null'],
'ignore_exceptions' => false,
],
'invoiceninja-single' => [
'driver' => 'single', 'driver' => 'single',
'path' => storage_path('logs/invoiceninja.log'), 'path' => storage_path('logs/invoiceninja.log'),
'level' => env('LOG_LEVEL', 'debug'), 'level' => env('LOG_LEVEL', 'debug'),
'days' => 7, 'days' => 7,
], ],
'invoiceninja-reminders' => [ 'invoiceninja-reminders' => [
'driver' => 'stack',
'channels' => ['invoiceninja-reminders-single', env('IS_DOCKER', false) ? 'stderr' : 'null'],
'ignore_exceptions' => false,
],
'invoiceninja-reminders-single' => [
'driver' => 'single', 'driver' => 'single',
'path' => storage_path('logs/invoiceninja-reminders.log'), 'path' => storage_path('logs/invoiceninja-reminders.log'),
'level' => env('LOG_LEVEL', 'debug'), 'level' => env('LOG_LEVEL', 'debug'),
'days' => 90, 'days' => 90,
], ],
'deprecations' => [
'driver' => 'stack',
'channels' => array_merge(explode(',', (string) env('LOG_DEPRECATIONS', 'single')), [env('IS_DOCKER', false) ? 'stderr' : 'null']),
],
'stack' => [ 'stack' => [
'driver' => 'stack', 'driver' => 'stack',
'channels' => ['single'], 'channels' => array_merge(explode(',', (string) env('LOG_STACK', 'single')), [env('IS_DOCKER', false) ? 'stderr' : 'null']),
'ignore_exceptions' => false, 'ignore_exceptions' => false,
'days' => 7,
], ],
'single' => [ 'single' => [
'driver' => 'single', 'driver' => 'single',
'path' => storage_path('logs/laravel.log'), 'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'), 'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
], ],
'daily' => [ 'daily' => [
'driver' => 'daily', 'driver' => 'daily',
'path' => storage_path('logs/laravel.log'), 'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'), 'level' => env('LOG_LEVEL', 'debug'),
'days' => 14, 'days' => env('LOG_DAILY_DAYS', 14),
'replace_placeholders' => true,
], ],
'slack' => [ 'slack' => [
'driver' => 'slack', 'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'), 'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log', 'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
'emoji' => ':boom:', 'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
'level' => env('LOG_LEVEL', 'critical'), 'level' => env('LOG_LEVEL', 'critical'),
'replace_placeholders' => true,
], ],
'papertrail' => [ 'papertrail' => [
@@ -101,26 +123,31 @@ return [
'port' => env('PAPERTRAIL_PORT'), 'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
], ],
'processors' => [PsrLogMessageProcessor::class],
], ],
'stderr' => [ 'stderr' => [
'driver' => 'monolog', 'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'), 'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class, 'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'), 'handler_with' => [
'with' => [
'stream' => 'php://stderr', 'stream' => 'php://stderr',
], ],
'formatter' => env('LOG_STDERR_FORMATTER'),
'processors' => [PsrLogMessageProcessor::class],
], ],
'syslog' => [ 'syslog' => [
'driver' => 'syslog', 'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'), 'level' => env('LOG_LEVEL', 'debug'),
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
'replace_placeholders' => true,
], ],
'errorlog' => [ 'errorlog' => [
'driver' => 'errorlog', 'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'), 'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
], ],
'null' => [ 'null' => [