netbirdio/netbird · error
failed initializing log %v
Error message
failed initializing log %v
What it means
util.InitLog(logLevel, "console") failed at CLI startup. Per util/log.go:38 the first thing InitLogger does is logrus.ParseLevel(logLevel), which accepts only panic, fatal, error, warn, warning, info, debug, trace (case-insensitive) - anything else (e.g. 'verbose', 'DEBUG ' with a space, an empty-ish typo) returns an error. With the "console" output target the log-writer branch cannot fail, so in practice this error always means the --log-level flag or its NB_LOG_LEVEL env var holds an invalid value.
Source
Thrown at client/cmd/login.go:468
cmd.Println("")
if !noBrowser {
if err := util.OpenBrowser(verificationURIComplete); err != nil {
cmd.Println("\nAlternatively, you may want to use a setup key, see:\n\n" +
"https://docs.netbird.io/how-to/register-machines-using-setup-keys")
}
}
}
func setEnvAndFlags(cmd *cobra.Command) error {
SetFlagsFromEnvVars(rootCmd)
cmd.SetOut(cmd.OutOrStdout())
err := util.InitLog(logLevel, "console")
if err != nil {
return fmt.Errorf("failed initializing log %v", err)
}
return nil
}
View on GitHub (pinned to 93e97f4bf1)
Solutions
- Use one of the valid levels: panic, fatal, error, warn, info, debug, or trace (warn and warning are both accepted)
- Check and fix the environment: echo the NB_LOG_LEVEL-style variable feeding logLevel and unset or correct it
- Grep scripts/CI config for the flag or env assignment supplying the bad value
- Validate the level before the CLI call when wrapping netbird in automation (see validation code)
Example fix
# before $ netbird login --log-level verbose Error: failed initializing log failed parsing log-level verbose: not a valid logrus Level: "verbose" # after $ netbird login --log-level debug
Defensive patterns
Strategy: validation
Validate before calling
// Validate the level before the CLI parses it
if _, err := logrus.ParseLevel(logLevel); err != nil {
return fmt.Errorf("invalid --log-level %q (valid: panic,fatal,error,warn,info,debug,trace)", logLevel)
}
err := util.InitLog(logLevel, "console") Type guard
// isValidLogLevel narrows accepted flag values before calling setEnvAndFlags
func isValidLogLevel(s string) bool {
_, err := logrus.ParseLevel(s)
return err == nil
} Try / catch
if err := util.InitLog(logLevel, "console"); err != nil {
return fmt.Errorf("failed initializing log: %w", err)
} Prevention
- Restrict scripts to the canonical levels: error, warn, info, debug, trace
- Lint CI env vars that feed netbird flags (catch NB_LOG_LEVEL typos)
- Note that 'warn' and 'warning' are both valid, but 'verbose' is not
When it happens
Trigger: Passing an unrecognized --log-level value; setting the environment variable that feeds logLevel (e.g. NB_LOG_LEVEL) to a non-level string; trailing whitespace or typos in automated scripts and unit tests that call setEnvAndFlags.
Common situations: Scripts copying log-level names from other tools (verbose, warning vs warn confusion, 'prod'); CI pipelines exporting a misspelled env var value; Shell profiles exporting a stale variable that predates a level rename
Related errors
- init log: %w
- startup check: no full status available
- startup check: management not connected
- startup check: signal not connected
- startup check: no relay servers available (0/%d connected)
AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16).
Data as JSON: /api/errors/04c966b49838cc9b.
Report an issue: GitHub.