grafana/k6 · error

unknown logfile config key %s

Error message

unknown logfile config key %s

What it means

A validation guard in parseArgs for the logfile configuration. Only 'file' and 'level' keys are accepted; it fires for any other token key. The at-fault input is the unknown key in the `file=...` config line.

Source

Thrown at internal/log/file.go:80

	tokens, err := strvals.Parse(line)
	if err != nil {
		return fmt.Errorf("error while parsing logfile configuration %w", err)
	}

	for _, token := range tokens {
		switch token.Key {
		case "file":
			if token.Value == "" {
				return fmt.Errorf("filepath must not be empty")
			}
			h.path = token.Value
		case "level":
			h.levels, err = parseLevels(token.Value)
			if err != nil {
				return err
			}
		default:
			return fmt.Errorf("unknown logfile config key %s", token.Key)
		}
	}

	return nil
}

// openFile opens logfile and initializes writers.
func (h *fileHook) openFile(getCwd func() (string, error)) error {
	path := h.path
	if !filepath.IsAbs(path) {
		cwd, err := getCwd()
		if err != nil {
			return fmt.Errorf("'%s' is a relative path but could not determine CWD: %w", path, err)
		}
		path = filepath.Join(cwd, path)
	}

	if _, err := h.fs.Stat(filepath.Dir(path)); errors.Is(err, fs.ErrNotExist) {

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Use only supported keys: file=<path> and level=<level>
  2. Remove or correct the unsupported key in the --log-output value
  3. Check for typos such as 'lvl' or 'path' instead of the accepted keys
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/log/file.go:80 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/abdd55c2a5830d64. Report an issue: GitHub.