{"record":{"id":"a11490292e5a2725","repo":"thanos-io/thanos","slug":"journald-log-format-requested-but-systemd-journal","errorCode":null,"errorMessage":"journald log format requested but systemd journal is not available","messagePattern":"journald log format requested but systemd journal is not available","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/logging/logger.go","lineNumber":60,"sourceCode":"\tcase \"info\":\n\t\tlvl = level.AllowInfo()\n\tcase \"debug\":\n\t\tlvl = level.AllowDebug()\n\tdefault:\n\t\t// This enum is already checked and enforced by flag validations, so\n\t\t// this should never happen.\n\t\tpanic(\"unexpected log level\")\n\t}\n\n\tlogger = log.NewLogfmtLogger(log.NewSyncWriter(os.Stderr))\n\tswitch logFormat {\n\tcase LogFormatJSON:\n\t\tlogger = log.NewJSONLogger(log.NewSyncWriter(os.Stderr))\n\tcase LogFormatJournald:\n\t\tif journal.Enabled() {\n\t\t\tlogger = newJournaldLogger()\n\t\t} else {\n\t\t\treturn nil, errors.New(\"journald log format requested but systemd journal is not available\")\n\t\t}\n\t}\n\n\t// Sort the logger chain to avoid expensive log.Valuer evaluation for disallowed level.\n\t// Ref: https://github.com/go-kit/log/issues/14#issuecomment-945038252\n\tlogger = log.With(logger, \"ts\", log.DefaultTimestampUTC, \"caller\", log.Caller(5))\n\tlogger = level.NewFilter(logger, lvl)\n\n\tif debugName != \"\" {\n\t\tlogger = log.With(logger, \"name\", debugName)\n\t}\n\n\treturn LevelLogger{\n\t\tLogger:   logger,\n\t\tLogLevel: logLevel,\n\t}, nil\n}\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/logging/logger.go#L42-L78","documentation":"NewLogger supports a journald log format, but it requires the process to run on a system with systemd journal available (journal.Enabled() from go-systemd). Requesting LogFormatJournald on a host without systemd journal (macOS, containers without journald socket, non-Linux) returns this error instead of silently degrading.","triggerScenarios":"Starting Thanos (main via flags) with --log.format=journald on a machine where journal.Enabled() is false — e.g. Docker containers without journald, macOS dev machines, or systemd-less distros.","commonSituations":"Copying a bare-metal journald config into a containerized deployment; running Thanos on macOS for local development with production flags; minimal images lacking libsystemd/journald socket.","solutions":["Switch --log.format to logfmt or JSON on hosts without systemd.","Run the process on the host (or a container with journald socket mounted) where journal.Enabled() is true.","Gate the journald format behind an environment check in your launcher script."],"exampleFix":"// before\n--log.format=journald   # in a plain Docker container\n// after\n--log.format=logfmt","handlingStrategy":"fallback","validationCode":"if format == \"journald\" && !journal.Enabled() {\n  fmt.Fprintln(os.Stderr, \"journald unavailable, falling back to logfmt\")\n  format = \"logfmt\"\n}","typeGuard":null,"tryCatchPattern":"logger, err := logging.NewLogger(opts)\nif err != nil { return nil, fmt.Errorf(\"logger init failed (check --log.format vs platform): %w\", err) }","preventionTips":["Only use journald format on systemd hosts","Default to logfmt/JSON in containers and macOS dev environments","Probe journal availability at deploy time and adjust flags"],"tags":["logging","journald","platform"],"backgroundTag":"unsupported-platform","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}