has(LogContextManager::class)) { $contextManager = new LogContextManager(); $container->singleton(LogContextManager::class, $contextManager); // Globalen Kontext mit App-Informationen initialisieren $contextManager->addGlobalData('app_version', $config->app->version); $contextManager->addGlobalData('environment', $config->app->environment->value); $contextManager->addGlobalTags('application', 'framework'); } $processorManager = new ProcessorManager(); // Set log level based on environment $minLevel = $config->app->isDebugEnabled() ? LogLevel::DEBUG : LogLevel::INFO; // Erstelle LogConfig für zentrale Pfadverwaltung $logConfig = new LogConfig($pathProvider); // Stelle sicher, dass alle Logverzeichnisse existieren $logConfig->ensureLogDirectoriesExist(); $redisConfig = new RedisConfig(host: 'redis', database: 2); $redisConnection = new RedisConnection($redisConfig, 'queue'); $queue = new RedisQueue($redisConnection, 'commands'); // Alternativ: FileQueue mit aufgelöstem Pfad // $queuePath = $pathProvider->resolvePath('storage/queue'); // $queue = new FileQueue($queuePath); // In production, we might want to exclude console handler $handlers = []; if (! $config->app->isProduction()) { $handlers[] = new ConsoleHandler(); } $handlers[] = new QueuedLogHandler($queue); $handlers[] = new WebHandler(); // MultiFileHandler für automatisches Channel-Routing $handlers[] = new MultiFileHandler( $logConfig, $pathProvider, $minLevel, '[{timestamp}] [{level_name}] [{channel}] {message}', 0644 ); // Fallback FileHandler für Kompatibilität (nur für 'app' Channel ohne Channel-Info) $handlers[] = new FileHandler( $logConfig->getLogPath('app'), $minLevel, '[{timestamp}] [{level_name}] {request_id}{channel}{message}', 0644, null, $pathProvider ); // LogContextManager aus Container holen $contextManager = $container->get(LogContextManager::class); return new DefaultLogger( minLevel: $minLevel, handlers: $handlers, processorManager: $processorManager, contextManager: $contextManager, ); } }