grafana/k6 · error

unsupported log output

Error message

unsupported log output '%s'

What it means

--log-output (or K6_LOG_OUTPUT) accepts only the exact values stderr, stdout, none, or values with the prefixes loki (e.g. loki=http://...) and file (e.g. file=k6.log). Anything else falls through to the default branch in setupLoggers and k6 exits with this error at startup, before any test runs.

Solutions

  1. Use a supported sink: --log-output=stderr (default), stdout, none, file=./k6.log, or loki=<url>
  2. For on-disk logs: --log-output=file=k6.log; for Loki: --log-output='loki=http://loki:3100/loki/api/v1/push'
  3. For syslog/journald collection, write to stdout/file and let the surrounding system (systemd, docker logging driver) ship it

Example fix

// before
k6 run --log-output=syslog script.js

// after
k6 run --log-output=file=k6.log script.js
Defensive patterns

Strategy: validation

Validate before calling

# validate --log-output before running
validate_log_output() {
  local v="$1"
  case "$v" in
    stderr|stdout|none|loki*|file*) return 0;;
    *) echo "unsupported log output '$v' (use stderr|stdout|none|file=...|loki=...)" >&2; return 1;;
  esac
}
validate_log_output "$K6_LOG_OUTPUT" || exit 1
k6 run script.js

Prevention

When it happens

Trigger: k6 run --log-output=syslog script.js; --log-output=journald; --log-output=cloud; a typo like stoud. Values that merely start with loki/file parse further and fail with a different message — this error is only for unrecognized prefixes/values.

Common situations: Assuming k6 supports syslog/journald because other CLIs do; porting logging config from other load-testing tools; CI templates with a wrong env value for K6_LOG_OUTPUT.

Related errors


AI-assisted analysis of grafana/k6@8d06114777 (2026-08-31). Data as JSON: /api/errors/4d67b1a5b7c4e122. Report an issue: GitHub.

Appendix: source

Thrown at internal/cmd/root.go:390

	case line == "none":
		c.globalState.Logger.SetOutput(io.Discard)
	case strings.HasPrefix(line, "loki"):
		c.loggerIsRemote = true
		hook, err = log.LokiFromConfigLine(c.globalState.FallbackLogger, line)
		if err != nil {
			return err
		}
		c.globalState.Flags.LogFormat = "raw"
	case strings.HasPrefix(line, "file"):
		hook, err = log.FileHookFromConfigLine(
			c.globalState.FS, c.globalState.Getwd,
			c.globalState.FallbackLogger, line,
		)
		if err != nil {
			return err
		}
	default:
		return fmt.Errorf("unsupported log output '%s'", line)
	}

	setupLogFormat(c, loggerForceColors)

	secretsources, err := createSecretSources(c.globalState)
	if err != nil {
		return err
	}
	// it is important that we add this hook first as hooks are executed in order of addition
	// and this means no other hook will get secrets
	var secretsHook logrus.Hook
	c.globalState.SecretsManager, secretsHook, err = secretsource.NewManager(secretsources)
	if err != nil {
		return err
	}
	if len(secretsources) != 0 {
		// don't actually filter anything if there will be no secrets
		c.globalState.Logger.AddHook(secretsHook)

View on GitHub (pinned to 8d06114777)