{"record":{"id":"0a7794f339b4957d","repo":"linera-io/linera-protocol","slug":"invalid-rust-log-format-format-valid-values","errorCode":null,"errorMessage":"Invalid RUST_LOG_FORMAT: `{format}`.  Valid values are `json` or `pretty`.","messagePattern":"Invalid RUST_LOG_FORMAT: `(.+?)`\\.  Valid values are `json` or `pretty`\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-service/src/tracing/mod.rs","lineNumber":211,"sourceCode":"    N: for<'writer> FormatFields<'writer> + Send + Sync + 'static,\n    W: for<'writer> MakeWriter<'writer> + Send + Sync + 'static,\n    T: FormatTime + Send + Sync + 'static,\n{\n    match formatting.unwrap_or(\"plain\") {\n        \"json\" => layer.json().boxed(),\n        \"pretty\" => layer.pretty().boxed(),\n        \"plain\" => {\n            #[cfg(not(target_arch = \"wasm32\"))]\n            {\n                layer.event_format(WithTraceContext).boxed()\n            }\n            #[cfg(target_arch = \"wasm32\")]\n            {\n                layer.boxed()\n            }\n        }\n        format => {\n            panic!(\"Invalid RUST_LOG_FORMAT: `{format}`.  Valid values are `json` or `pretty`.\")\n        }\n    }\n}\n\npub(crate) fn fmt_span_from_str(events: &str) -> FmtSpan {\n    let mut fmt_span = FmtSpan::NONE;\n    for event in events.split(',') {\n        fmt_span |= match event {\n            \"new\" => FmtSpan::NEW,\n            \"enter\" => FmtSpan::ENTER,\n            \"exit\" => FmtSpan::EXIT,\n            \"close\" => FmtSpan::CLOSE,\n            \"active\" => FmtSpan::ACTIVE,\n            \"full\" => FmtSpan::FULL,\n            _ => FmtSpan::NONE,\n        };\n    }\n    fmt_span","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-service/src/tracing/mod.rs#L193-L229","documentation":"prepare_formatted_layer selects the tracing output format from the RUST_LOG_FORMAT environment variable. Recognized values are 'json' and 'pretty' (plus wasm-specific handling); anything else falls into the catch-all arm and panics with a message listing the valid values. The function feeds stderr_layer and maybe_log_file_layer, so it runs during logging initialization in linera-service binaries.","triggerScenarios":"Starting any linera-service binary (validator, proxy, node, faucet, indexer CLI tooling) with RUST_LOG_FORMAT set to something other than json/pretty — e.g. 'JSON', 'text', 'logfmt', 'plain', or a value with trailing whitespace/newline.","commonSituations":"CI pipelines or container env files exporting generic logging variables copied from other stacks (LOG_FORMAT=text); shell quoting mistakes; docker-compose env entries with stray spaces.","solutions":["Set RUST_LOG_FORMAT=json or RUST_LOG_FORMAT=pretty exactly, or unset it to use the default","Strip whitespace/casing issues in deployment env files","Audit environment templates for copied-in logging variables from other frameworks"],"exampleFix":"# before\nexport RUST_LOG_FORMAT=text   # panics\n\n# after\nexport RUST_LOG_FORMAT=pretty  # or: unset RUST_LOG_FORMAT","handlingStrategy":"validation","validationCode":"fn valid_log_format(v: &str) -> bool { matches!(v.trim(), \"json\" | \"pretty\") }\nif let Ok(format) = std::env::var(\"RUST_LOG_FORMAT\") {\n    assert!(valid_log_format(&format), \"RUST_LOG_FORMAT must be json or pretty\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document allowed values next to wherever RUST_LOG_FORMAT is set (compose files, systemd units)","Validate logging env vars in entrypoint scripts before exec'ing the binary"],"tags":["logging","tracing","environment-variable","configuration","startup"],"backgroundTag":"invalid-env-var-value","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}