karatelabs/karate · warning

invalid karate.options log-report ignored

Error message

invalid karate.options log-report ignored: {}

What it means

The `--log-report` (logReport) value from `karate.options` is converted to a LogLevel via LogLevel.valueOf(value.toUpperCase()). If the value is not one of the LogLevel enum constant names, the conversion throws IllegalArgumentException, which is caught and logged as this warning; the invalid log level is ignored and the report log level stays at the builder default.

Solutions

  1. Use one of the exact LogLevel enum constant names (e.g. `--log-report DEBUG`), case-insensitive thanks to toUpperCase().
  2. Check the LogLevel enum in the installed karate version for the accepted values — the set can differ between versions.
  3. Map framework names manually: use WARN instead of `warning`, INFO instead of `informational`.
  4. If a custom level is needed, configure the logger outside karate.options (LogContext / logging backend config).

Example fix

// before
-Dkarate.options="--log-report verbose"
// after
-Dkarate.options="--log-report TRACE"
Defensive patterns

Strategy: validation

Validate before calling

String v = System.getProperty("karate.options");
// ensure --log-report value is a LogLevel constant
java.util.regex.Matcher m = java.util.regex.Pattern.compile("--log-report[ =](\\S+)").matcher(v == null ? "" : v);
if (m.find()) {
    try { io.karatelabs.output.LogLevel.valueOf(m.group(1).toUpperCase()); }
    catch (IllegalArgumentException e) { throw new IllegalArgumentException("invalid --log-report: " + m.group(1)); }
}

Prevention

When it happens

Trigger: Passing `--log-report` (or the logReport entry in `karate.options`) with a value that is not a valid LogLevel constant, e.g. `--log-report verbose`, `--log-report warn` if only WARN/DEBUG/TRACE/OFF/... are defined, or a misspelled name.

Common situations: Guessing level names instead of checking the LogLevel enum; typos like `infO` handled by toUpperCase but `warning` not mapping to WARN; copying levels from a different logging framework (slf4j/log4j custom names).

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12). Data as JSON: /api/errors/2b64b18ee2461bc8. Report an issue: GitHub.

Appendix: source

Thrown at karate-core/src/main/java/io/karatelabs/core/KarateOptionsHandler.java:275

        }

        // --- Formats (--format / -f) — only apply if the user set something ---
        List<String> parsedFormats = parsed.getFormats();
        if (parsedFormats != null && !parsedFormats.isEmpty()) {
            builder.setOutputHtmlReport(RunCommand.isFormatEnabled(parsedFormats, "html", true));
            builder.setOutputCucumberJson(RunCommand.isFormatEnabled(parsedFormats, "cucumber:json", false));
            builder.setOutputJunitXml(RunCommand.isFormatEnabled(parsedFormats, "junit:xml", false));
            builder.setOutputJsonLines(RunCommand.isFormatEnabled(parsedFormats, "karate:jsonl", false));
            summary.add("formats=" + parsedFormats);
        }

        // --- Log levels ---
        if (parsed.getLogReport() != null) {
            try {
                builder.setLogLevel(LogLevel.valueOf(parsed.getLogReport().toUpperCase()));
                summary.add("logReport=" + parsed.getLogReport());
            } catch (IllegalArgumentException ex) {
                logger.warn("invalid karate.options log-report ignored: {}", parsed.getLogReport());
            }
        }
        if (parsed.getLogConsole() != null) {
            io.karatelabs.output.LogContext.setRuntimeLogLevel(parsed.getLogConsole());
            summary.add("logConsole=" + parsed.getLogConsole());
        }

        if (!summary.isEmpty()) {
            logger.info("karate.options applied: {}", String.join(", ", summary));
        }

        return effectiveThreads;
    }

    private static String trimToNull(String s) {
        if (s == null) return null;
        String t = s.trim();
        return t.isEmpty() ? null : t;

View on GitHub (pinned to a22eb90246)