gohugoio/hugo · error
invalid log level: %q, must be one of debug, warn, info or e
Error message
invalid log level: %q, must be one of debug, warn, info or error
What it means
Emitted while building the logger when the `--logLevel` flag value doesn't match one of the accepted names. Hugo lowercases the value and accepts only `debug`, `info`, `warn`/`warning`, and `error`; anything else aborts startup so a typo can't silently run with the wrong verbosity. Note `--logLevel` is ignored entirely in dev mode, which forces trace.
Source
Thrown at commands/commandeer.go:509
func (r *rootCommand) createLogger(running bool) (loggers.Logger, error) {
level := logg.LevelWarn
if r.devMode {
level = logg.LevelTrace
} else {
if r.logLevel != "" {
switch strings.ToLower(r.logLevel) {
case "debug":
level = logg.LevelDebug
case "info":
level = logg.LevelInfo
case "warn", "warning":
level = logg.LevelWarn
case "error":
level = logg.LevelError
default:
return nil, fmt.Errorf("invalid log level: %q, must be one of debug, warn, info or error", r.logLevel)
}
}
}
var logHookLast func(e *logg.Entry) error
if r.panicOnWarning {
logHookLast = loggers.PanicOnWarningHook
}
optsLogger := loggers.Options{
DistinctLevel: logg.LevelWarn,
Level: level,
StdOut: r.StdOut,
StdErr: r.StdErr,
StoreErrors: running,
HandlerPost: logHookLast,
}
View on GitHub ↗ (pinned to 8a468df065)
Solutions
- Change the flag to one of the accepted values: `--logLevel info` (or debug, warn, error).
- If you wanted trace-level output, there is no public trace level — use `--logLevel debug`.
- In scripts, replace removed `--verbose`/`--debug` flags with `--logLevel info`/`--logLevel debug`.
Example fix
# before hugo --logLevel verbose # after hugo --logLevel info
Defensive patterns
Strategy: validation
Validate before calling
validLevels := map[string]bool{"debug": true, "info": true, "warn": true, "error": true}
if !validLevels[strings.ToLower(level)] {
return fmt.Errorf("invalid --logLevel %q; use debug|info|warn|error", level)
} Type guard
func isValidLogLevel(s string) bool {
switch strings.ToLower(s) {
case "debug", "info", "warn", "error":
return true
}
return false
} Prevention
- Validate CLI flags against the enumerated set before invoking hugo
- Don't pass legacy values like "trace" or "warning"; map them to the supported four
- Centralize the allowed-levels list so scripts and docs stay in sync
When it happens
Trigger: Any Hugo invocation with `--logLevel <value>` where the lowercased value isn't debug/info/warn/warning/error — e.g. `--logLevel verbose`, `--logLevel trace`, `--logLevel DEBUG2`.
Common situations: Muscle memory from other tools using `trace`, `fatal`, or `verbose` levels; scripts written for the pre-0.114 `--verbose`/`--debug` flags migrated incorrectly; env-driven CI variables containing stray whitespace or wrong values.
Related errors
- invalid value for flag poll: %s
- language %q not found
- unsupported format: %q
- deploy not supported in this version of Hugo; install a rele
- target path "%s" exists but is not a directory
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/28a3134f4edb15b3.json.
Report an issue: GitHub ↗.