🔍 The Problem
When setting LISTENARR_LOG_LEVEL=Trace, the application silently drops logging verbosity to Information rather than raising it to maximum diagnostic detail. During troubleshooting scenarios, this silent fallback concealed critical diagnostic events—logging only 124 lines compared to 205 lines under debug/verbose levels, obscuring the underlying causes of failures.
In listenarr.api/Startup/ListenarrBuilderFactory.cs (ConfigureSerilog), log level strings from both the LISTENARR_LOG_LEVEL environment variable and configuration (Serilog:MinimumLevel:Default or Logging:LogLevel:Default) were parsed directly via Enum.TryParse<LogEventLevel>. Unlike Microsoft.Extensions.Logging where Trace denotes level 0 (the most verbose level), Serilog's LogEventLevel enum defines Verbose as level 0 and lacks a Trace member (and defines Fatal rather than Critical). Because Enum.TryParse<LogEventLevel>("Trace", ...) returned false, execution silently fell through to the default fallback LogEventLevel.Information without issuing any warnings or alerts. Consequently, setting LISTENARR_LOG_LEVEL=Trace inadvertently suppressed all Verbose and Debug logs.
🛠️ The Solution
-
Implemented
TryParseLogLevelinlistenarr.api/Startup/ListenarrBuilderFactory.csto trim input whitespace, map.NETstandard aliases (TracetoLogEventLevel.VerboseandCriticaltoLogEventLevel.Fatal) case-insensitively, and delegate standard levels toEnum.TryParse<LogEventLevel>. -
Implemented
ResolveMinimumLevelinListenarrBuilderFactory.cswith deterministic precedence (LISTENARR_LOG_LEVELenvironment variable takes precedence over configuration), linear fallback toLogEventLevel.Information, and a decoupled warning logger delegate. -
Added structured diagnostic console warnings (
[Listenarr] Warning: Unrecognized log level...) when invalid or mistyped log levels are supplied via environment...
Automated Canary build