{"record":{"id":"2b64b18ee2461bc8","repo":"karatelabs/karate","slug":"invalid-karate-options-log-report-ignored","errorCode":null,"errorMessage":"invalid karate.options log-report ignored: {}","messagePattern":"invalid karate\\.options log-report ignored: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/core/KarateOptionsHandler.java","lineNumber":275,"sourceCode":"        }\n\n        // --- Formats (--format / -f) — only apply if the user set something ---\n        List<String> parsedFormats = parsed.getFormats();\n        if (parsedFormats != null && !parsedFormats.isEmpty()) {\n            builder.setOutputHtmlReport(RunCommand.isFormatEnabled(parsedFormats, \"html\", true));\n            builder.setOutputCucumberJson(RunCommand.isFormatEnabled(parsedFormats, \"cucumber:json\", false));\n            builder.setOutputJunitXml(RunCommand.isFormatEnabled(parsedFormats, \"junit:xml\", false));\n            builder.setOutputJsonLines(RunCommand.isFormatEnabled(parsedFormats, \"karate:jsonl\", false));\n            summary.add(\"formats=\" + parsedFormats);\n        }\n\n        // --- Log levels ---\n        if (parsed.getLogReport() != null) {\n            try {\n                builder.setLogLevel(LogLevel.valueOf(parsed.getLogReport().toUpperCase()));\n                summary.add(\"logReport=\" + parsed.getLogReport());\n            } catch (IllegalArgumentException ex) {\n                logger.warn(\"invalid karate.options log-report ignored: {}\", parsed.getLogReport());\n            }\n        }\n        if (parsed.getLogConsole() != null) {\n            io.karatelabs.output.LogContext.setRuntimeLogLevel(parsed.getLogConsole());\n            summary.add(\"logConsole=\" + parsed.getLogConsole());\n        }\n\n        if (!summary.isEmpty()) {\n            logger.info(\"karate.options applied: {}\", String.join(\", \", summary));\n        }\n\n        return effectiveThreads;\n    }\n\n    private static String trimToNull(String s) {\n        if (s == null) return null;\n        String t = s.trim();\n        return t.isEmpty() ? null : t;","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/KarateOptionsHandler.java#L257-L293","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Use one of the exact LogLevel enum constant names (e.g. `--log-report DEBUG`), case-insensitive thanks to toUpperCase().","Check the LogLevel enum in the installed karate version for the accepted values — the set can differ between versions.","Map framework names manually: use WARN instead of `warning`, INFO instead of `informational`.","If a custom level is needed, configure the logger outside karate.options (LogContext / logging backend config)."],"exampleFix":"// before\n-Dkarate.options=\"--log-report verbose\"\n// after\n-Dkarate.options=\"--log-report TRACE\"","handlingStrategy":"validation","validationCode":"String v = System.getProperty(\"karate.options\");\n// ensure --log-report value is a LogLevel constant\njava.util.regex.Matcher m = java.util.regex.Pattern.compile(\"--log-report[ =](\\\\S+)\").matcher(v == null ? \"\" : v);\nif (m.find()) {\n    try { io.karatelabs.output.LogLevel.valueOf(m.group(1).toUpperCase()); }\n    catch (IllegalArgumentException e) { throw new IllegalArgumentException(\"invalid --log-report: \" + m.group(1)); }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use LogLevel enum constant names for --log-report (TRACE, DEBUG, INFO, WARN, ERROR, OFF as applicable)","Check the LogLevel enum of your karate version rather than assuming slf4j/log4j level names","Keep a shared CI script that builds karate.options so level strings are defined in one place"],"tags":["logging","log-level","enum-value","karate-options"],"backgroundTag":"invalid-enum-value","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}