{"record":{"id":"8e7869938318b623","repo":"apache/maven","slug":"is-not-a-valid-log-severity-threshold-valid-se","errorCode":null,"errorMessage":"{} is not a valid log severity threshold. Valid severities are WARN/WARNING and ERROR.","messagePattern":"(.+?) is not a valid log severity threshold\\. Valid severities are WARN/WARNING and ERROR\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compat/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java","lineNumber":582,"sourceCode":"                //\n            }\n        }\n\n        slf4jConfiguration.activate();\n\n        plexusLoggerManager = new Slf4jLoggerManager();\n        slf4jLogger = slf4jLoggerFactory.getLogger(this.getClass().getName());\n\n        if (commandLine.hasOption(CLIManager.FAIL_ON_SEVERITY)) {\n            String logLevelThreshold = commandLine.getOptionValue(CLIManager.FAIL_ON_SEVERITY);\n\n            if (slf4jLoggerFactory instanceof LogLevelRecorder recorder) {\n                LogLevelRecorder.Level level =\n                        switch (logLevelThreshold.toLowerCase(Locale.ENGLISH)) {\n                            case \"warn\", \"warning\" -> LogLevelRecorder.Level.WARN;\n                            case \"error\" -> LogLevelRecorder.Level.ERROR;\n                            default ->\n                                throw new IllegalArgumentException(\n                                        logLevelThreshold\n                                                + \" is not a valid log severity threshold. Valid severities are WARN/WARNING and ERROR.\");\n                        };\n                recorder.setMaxLevelAllowed(level);\n                slf4jLogger.info(\"Enabled to break the build on log level {}.\", logLevelThreshold);\n            } else {\n                slf4jLogger.warn(\n                        \"Expected LoggerFactory to be of type '{}', but found '{}' instead. \"\n                                + \"The --fail-on-severity flag will not take effect.\",\n                        LogLevelRecorder.class.getName(),\n                        slf4jLoggerFactory.getClass().getName());\n            }\n        }\n\n        // check for presence of deprecated options and print warning\n        boolean fail = false;\n        for (Option option : cliRequest.commandLine.getOptions()) {\n            if (option.isDeprecated()) {","sourceCodeStart":564,"sourceCodeEnd":600,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java#L564-L600","documentation":"The --fail-on-severity / --fos option asks Maven to fail the build when log output reaches a given severity. MavenCli validates the argument against a fixed switch accepting only 'warn', 'warning', and 'error' (case-insensitive via toLowerCase(Locale.ENGLISH)); anything else throws IllegalArgumentException. The validation only runs when the active SLF4J factory implements LogLevelRecorder (Maven's built-in maven-slf4j-provider does); with an external binding (logback, log4j, etc.) the flag is instead ignored with a warning and no exception is thrown.","triggerScenarios":"mvn --fail-on-severity=INFO, --fos=DEBUG, --fos=TRACE, --fos=FATAL, or any non-empty value other than warn/warning/error, while the default Maven SLF4J provider is active. Values supplied through wrapper scripts or .mvn/maven.config (e.g. --fos info) hit the same path.","commonSituations":"Assuming the full log4j/slf4j level hierarchy (TRACE/DEBUG/INFO/WARN/ERROR/FATAL) is accepted. Copying configurations from Maven 3.9.x-era tooling or blog posts that used different severity names. Trying to fail on INFO-level messages, which this option deliberately does not support.","solutions":["Use one of the supported values: --fail-on-severity=error (strict, default behavior) or --fail-on-severity=warn / warning (also fails on warnings).","Check .mvn/maven.config, wrapper scripts, and CI pipeline definitions for a stale --fos value and correct it.","If you intended to fail on lower-severity messages, note it is unsupported by design; filter or grep the build log in your pipeline instead.","If you saw only a warning instead of this error, replace the external SLF4J binding with the Maven default provider so the flag takes effect."],"exampleFix":"# before\nmvn --fail-on-severity=INFO\n\n# after\nmvn --fail-on-severity=WARN","handlingStrategy":"validation","validationCode":"// Before building mvn args\nString severity = \"warn\"; // from config\nif (!Set.of(\"warn\", \"warning\", \"error\").contains(severity.toLowerCase(Locale.ENGLISH))) {\n    throw new IllegalArgumentException(\"--fail-on-severity must be WARN/WARNING/ERROR, got: \" + severity);\n}\nList<String> args = List.of(\"--fail-on-severity=\" + severity.toLowerCase(Locale.ENGLISH));","typeGuard":null,"tryCatchPattern":"try {\n    mavenCli.doMain(args, ...);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().endsWith(\"is not a valid log severity threshold. Valid severities are WARN/WARNING and ERROR.\")) {\n        // normalize config to WARN or ERROR and re-invoke once\n    }\n    throw e;\n}","preventionTips":["Allow-list the value in your pipeline templates (dropdown with WARN/ERROR) rather than free text.","Remember only the default Maven SLF4J provider enforces the flag; with an external binding the whole option is silently inert.","CI lint: reject --fos/--fail-on-severity values other than warn/warning/error."],"tags":["maven","cli","logging","fail-on-severity","invalid-value"],"backgroundTag":"invalid-log-level","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}