{"record":{"id":"909b4450f10d8eb3","repo":"stalwartlabs/stalwart","slug":"journald-does-not-exist-in-this-environment","errorCode":null,"errorMessage":"journald does not exist in this environment","messagePattern":"journald does not exist in this environment","errorType":"exception","errorClass":"io::Error(NotFound)","httpStatus":null,"severity":"error","filePath":"crates/common/src/telemetry/tracers/journald.rs","lineNumber":205,"sourceCode":"            let socket = UnixDatagram::unbound()?;\n            let sub = Self {\n                socket,\n                syslog_identifier: std::env::current_exe()\n                    .ok()\n                    .as_ref()\n                    .and_then(|p| p.file_name())\n                    .map(|n| n.to_string_lossy().into_owned())\n                    // If we fail to get the name of the current executable fall back to an empty string.\n                    .unwrap_or_default(),\n                priority_mappings: PriorityMappings::new(),\n            };\n            // Check that we can talk to journald, by sending empty payload which journald discards.\n            // However if the socket didn't exist or if none listened we'd get an error here.\n            sub.send_payload(&[])?;\n            Ok(sub)\n        }\n        #[cfg(not(unix))]\n        Err(io::Error::new(\n            io::ErrorKind::NotFound,\n            \"journald does not exist in this environment\",\n        ))\n    }\n\n    /// Sets how [`tracing_core::Level`]s are mapped to [journald priorities](Priority).\n    ///\n    pub fn with_priority_mappings(mut self, mappings: PriorityMappings) -> Self {\n        self.priority_mappings = mappings;\n        self\n    }\n\n    /// Sets the syslog identifier for this logger.\n    ///\n    /// The syslog identifier comes from the classic syslog interface (`openlog()`\n    /// and `syslog()`) and tags log entries with a given identifier.\n    /// Systemd exposes it in the `SYSLOG_IDENTIFIER` journal field, and allows\n    /// filtering log messages by syslog identifier with `journalctl -t`.","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/stalwartlabs/stalwart/blob/e96200385781a6a9995a8b839ac27d6c75a983ee/crates/common/src/telemetry/tracers/journald.rs#L187-L223","documentation":"Constructing the journald tracer on a non-Unix platform is unsupported: journald is a Linux/systemd facility, so `new` returns an io::Error of kind NotFound. It cannot talk to the journald socket, so the tracer cannot be created at all.","triggerScenarios":"Calling journald tracer `new()` (e.g. while initializing telemetry) compiled for non-Unix targets — the #[cfg(not(unix))] branch unconditionally returns this error.","commonSituations":"Running Stalwart on Windows with journald selected as telemetry tracer; cross-compiling and shipping a build with journald enabled in config.","solutions":["Switch the telemetry tracer to a supported output (e.g. log file, stdout) on non-Unix platforms.","Run the service on Linux/systemd if journald output is required.","Gate journald selection in configuration per-platform at deployment time."],"exampleFix":"// before (config.toml)\n[telemetry.tracer.journald]\nenabled = true // on Windows\n// after (config.toml)\n[telemetry.tracer.file]\nenabled = true\npath = \"/var/log/stalwart\"","handlingStrategy":"fallback","validationCode":"// pick tracer per platform at startup\nlet tracer = if cfg!(unix) { journald_tracer() } else { file_tracer().await };","typeGuard":"fn journald_supported() -> bool { cfg!(unix) }","tryCatchPattern":"let tracer = match Journald::new() {\n    Ok(t) => t,\n    Err(e) => { log::warn!(\"journald unavailable ({e}); using file tracer\"); file_tracer().await },\n};","preventionTips":["Only enable journald telemetry on Linux/systemd deployments.","Keep a fallback tracing sink configured for every host.","Test telemetry initialization on the target OS in CI.","Document platform constraints in deployment configs."],"tags":["logging","journald","platform","telemetry"],"backgroundTag":"unsupported-platform","analyzedSha":"e96200385781a6a9995a8b839ac27d6c75a983ee","analyzedAt":"2026-09-06T22:07:17.982Z","contentChangedAt":"2026-09-06T22:07:17.982Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}