amir20/dozzle · critical

panic(err) on invalid --level value

Error message

panic(err) on invalid --level value

What it means

ConfigureLogger validates the --level value with zerolog.ParseLevel and panics if it is not one of the accepted levels (trace, debug, info, warn, error, fatal, panic, disabled). This is a fail-fast crash at startup for invalid CLI/env configuration.

Solutions

  1. Set --level or DOZZLE_LEVEL to a valid lowercase zerolog level: trace, debug, info, warn, error, fatal, panic, or disabled.
  2. Strip surrounding whitespace and lowercase the value in deployment config.
  3. Remove the DOZZLE_LEVEL env var entirely to use the default level.

Example fix

# before
environment:
  - DOZZLE_LEVEL=INFO
# after
environment:
  - DOZZLE_LEVEL=info
Defensive patterns

Strategy: validation

Validate before calling

const VALID_LEVELS = ['trace','debug','info','warn','error','fatal','panic','disabled'];
const level = (process.env.DOZZLE_LEVEL || 'info').trim().toLowerCase();
if (!VALID_LEVELS.includes(level)) throw new Error(`invalid --level value: ${level}`);

Prevention

When it happens

Trigger: Starting dozzle with --level=verbose, --level=INFO (uppercase), or DOZZLE_LEVEL=logging; any value outside zerolog's enum panics during ParseArgs/ConfigureLogger.

Common situations: Typo in docker-compose DOZZLE_LEVEL env var; copying a level name from another logging library (e.g. log4j "INFO"); automation scripts passing empty or numeric levels.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of amir20/dozzle@d9463cbe21 (2026-09-07). Data as JSON: /api/errors/19f628777c183d8d. Report an issue: GitHub.

Appendix: source

Thrown at internal/support/cli/logger.go:15

package cli

import (
	"os"

	"github.com/rs/zerolog"
	"github.com/rs/zerolog/log"
)

func ConfigureLogger(level string) {
	if level, err := zerolog.ParseLevel(level); err == nil {
		zerolog.SetGlobalLevel(level)
		log.Logger = log.With().Str("version", Version).Logger()
	} else {
		panic(err)
	}

	_, dev := os.LookupEnv("DEV")

	if dev {
		writer := zerolog.NewConsoleWriter(func(w *zerolog.ConsoleWriter) {
			w.FieldsOrder = []string{"id", "from", "to", "since"}
		})
		log.Logger = log.Output(writer)
	}
}

View on GitHub (pinned to d9463cbe21)