slackhq/nebula · error
unknown log format `%s`. possible formats: %s
Error message
unknown log format `%s`. possible formats: %s
What it means
SetFormat validates the requested log format against the supported set ('text' and 'json') and returns this error for anything else. It is an input validation error on the Handler's format configuration.
Source
Thrown at logging/logger.go:143
// SetLevel updates the effective log level. Propagates to every derived
// logger via the shared LevelVar.
func (h *Handler) SetLevel(level slog.Level) { h.root.level.Set(level) }
// GetLevel reports the current log level.
func (h *Handler) GetLevel() slog.Level { return h.root.level.Level() }
// SetFormat flips the output format atomically. Valid formats are "text"
// and "json". Every derived logger sees the new format on its next Handle
// call; no rebuild or registration is required.
func (h *Handler) SetFormat(format string) error {
switch format {
case "text":
h.root.jsonMode.Store(false)
case "json":
h.root.jsonMode.Store(true)
default:
return fmt.Errorf("unknown log format `%s`. possible formats: %s", format, []string{"text", "json"})
}
return nil
}
// GetFormat reports the currently selected format name.
func (h *Handler) GetFormat() string {
if h.root.jsonMode.Load() {
return "json"
}
return "text"
}
// SetDisableTimestamp toggles whether Handle zeroes r.Time before
// dispatching (slog's builtin text/json handlers skip emitting the time
// attribute on a zero time).
func (h *Handler) SetDisableTimestamp(v bool) { h.root.disableTimestamp.Store(v) }
// ApplyConfig reads logging.level, logging.format, and (optionally)View on GitHub (pinned to dd8f660c0a)
Solutions
- Pass exactly "text" or "json" to SetFormat
- Normalize/trim the format string before calling SetFormat
- Default to "text" when the config value is absent
Example fix
// before
err := h.SetFormat("logfmt")
// after
format := strings.ToLower(strings.TrimSpace(cfg.Format))
if format != "json" {
format = "text"
}
err := h.SetFormat(format) Defensive patterns
Strategy: validation
Validate before calling
switch strings.ToLower(strings.TrimSpace(format)) {
case "text", "json", "":
// ok
default:
return fmt.Errorf("unsupported log format %q", format)
} Prevention
- Use only 'text' or 'json' for logging.format
- Normalize case/whitespace before calling SetFormat
- Handle SetFormat's error at startup rather than ignoring it
When it happens
Trigger: Calling Handler.SetFormat with any string other than "text" or "json", e.g. "logfmt", "TEXT", or empty string.
Common situations: Typo in config 'logging.format'; case sensitivity; copying formats from another logging library that supports logfmt/syslog.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- not a valid logging level: %q
- unknown protocol %v
- %s failed to parse, should be an array of rules
- %s rule #%v; only one of port or code should be provided
- %s rule #%v; at least one of host, group, cidr, local_cidr,
AI-assisted analysis of slackhq/nebula@dd8f660c0a (2026-09-03).
Data as JSON: /api/errors/1b37e23dfb15a64f.
Report an issue: GitHub.