{"record":{"id":"ddeed222449cb40c","repo":"stalwartlabs/stalwart","slug":"invalid-log-level","errorCode":null,"errorMessage":"Invalid LOG level","messagePattern":"Invalid LOG level","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/config/telemetry.rs","lineNumber":530,"sourceCode":"\n                // Parse webhook events\n                apply_events(hook.events, hook.events_policy, |event_type| {\n                    if event_type != EventType::Telemetry(TelemetryEvent::WebhookError) {\n                        tracer.interests.set(event_type);\n                        global_interests.set(event_type);\n                    }\n                });\n\n                if !tracer.interests.is_empty() {\n                    tracers.push(tracer);\n                } else {\n                    bp.build_error(id, \"No events enabled for webhook\");\n                }\n            }\n\n            #[cfg(feature = \"dev_mode\")]\n            if let Ok(level) = std::env::var(\"LOG\") {\n                let level = Level::from_str(&level).expect(\"Invalid LOG level\");\n                for event_type in EventType::variants() {\n                    let event_level = custom_levels\n                        .get(event_type)\n                        .copied()\n                        .unwrap_or(event_type.level());\n                    if level.is_contained(event_level) {\n                        global_interests.set(event_type.to_id() as usize);\n                    }\n                }\n\n                tracers.push(TelemetrySubscriber {\n                    id: \"default\".to_string(),\n                    interests: global_interests.clone(),\n                    typ: TelemetrySubscriberType::ConsoleTracer(ConsoleTracer {\n                        ansi: true,\n                        multiline: false,\n                        buffered: true,\n                    }),","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/stalwartlabs/stalwart/blob/e96200385781a6a9995a8b839ac27d6c75a983ee/crates/common/src/config/telemetry.rs#L512-L548","documentation":"This panic comes from `Level::from_str(&level).expect(\"Invalid LOG level\")` during telemetry/tracer setup in `parse`. The `LOG` environment variable is read only when the `dev_mode` feature is enabled, and it must parse into a trc `Level` via `Level::from_str`. That parser (crates/trc/src/event/level.rs:44) only accepts the case-insensitive strings \"disable\", \"trace\", \"debug\", \"info\", \"warn\", and \"error\"; anything else makes `from_str` return `Err` and the `expect` panics with \"Invalid LOG level\", aborting configuration parsing.","triggerScenarios":"Setting the LOG env var (with the binary built with the dev_mode feature) to anything outside {disable, trace, debug, info, warn, error} — e.g. LOG=verbose, LOG=5, LOG=warning, LOG=trace,debug (a comma-separated RUST_LOG-style filter is NOT accepted), or a value with surrounding whitespace/newline.","commonSituations":"Developers copying RUST_LOG-style syntax (\"info,foo=debug\") from other Rust projects; typing \"warning\" or \"critical\" instead of \"warn\"/\"error\"; numeric log levels; exporting LOG=\"info \" with a trailing space in a shell profile or Docker ENV; running a dev_mode build in an environment where LOG was set for an unrelated tool.","solutions":["Set LOG to one of the exact accepted values (case-insensitive): disable, trace, debug, info, warn, or error — e.g. LOG=debug.","Remove RUST_LOG-style per-module filters; a single level token is the only accepted form.","Trim whitespace from the value: export LOG=\"$(echo \"$LOG\" | tr -d '[:space:]')\" or fix the Dockerfile/systemd unit/export that introduces it.","If you meant per-event granularity, use the config's event log level settings (custom_levels) instead of the LOG env var.","If you are not intentionally running a dev_mode build, unset LOG entirely — the var is only read when the dev_mode feature is compiled in."],"exampleFix":"// before\nLOG=warning stalwart-mailserver   # panics: Invalid LOG level\n\n// after\nLOG=warn stalwart-mailserver","handlingStrategy":"validation","validationCode":"const VALID_LEVELS: [&str; 6] = [\"disable\", \"trace\", \"debug\", \"info\", \"warn\", \"error\"];\nlet log = std::env::var(\"LOG\").unwrap_or_default();\nassert!(VALID_LEVELS.contains(&log.to_ascii_lowercase().as_str()), \"LOG must be one of {:?}, got {:?}\", VALID_LEVELS, log);","typeGuard":"fn is_valid_log_level(s: &str) -> bool {\n    matches!(s.to_ascii_lowercase().as_str(), \"disable\" | \"trace\" | \"debug\" | \"info\" | \"warn\" | \"error\")\n}","tryCatchPattern":null,"preventionTips":["Never export a RUST_LOG-style filter string in LOG; it accepts a single level token only.","Use \"warn\", not \"warning\"; use \"error\", not \"critical\".","Trim whitespace when setting env vars in Dockerfiles/systemd units.","In production builds (no dev_mode), configure log levels via config file settings instead of the LOG env var."],"tags":["environment-variable","configuration","panic","logging","dev-mode"],"backgroundTag":"invalid-env-var-value","analyzedSha":"e96200385781a6a9995a8b839ac27d6c75a983ee","analyzedAt":"2026-09-06T22:07:17.982Z","contentChangedAt":"2026-09-06T22:07:17.982Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}