{"record":{"id":"724a37f79145ba3f","repo":"SonarSource/sonarqube","slug":"s-log-level-is-not-supported-allowed-levels-are","errorCode":null,"errorMessage":"%s log level is not supported (allowed levels are %s)","messagePattern":"(.+?) log level is not supported \\(allowed levels are (.+?)\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java","lineNumber":157,"sourceCode":"    rootContext.getLogger(loggerName).setLevel(newLevel);\n  }\n\n  private static void applyHardUnlessTrace(LoggerContext rootContext, String logger, boolean traceGloballyEnabled) {\n    if (!traceGloballyEnabled) {\n      rootContext.getLogger(logger).setLevel(Level.OFF);\n    }\n  }\n\n  public void changeRoot(LogLevelConfig logLevelConfig, Level newLevel) {\n    ensureSupportedLevel(newLevel);\n    LoggerContext rootContext = getRootContext();\n    rootContext.getLogger(ROOT_LOGGER_NAME).setLevel(newLevel);\n    logLevelConfig.getConfiguredByProperties().forEach((key, value) -> rootContext.getLogger(key).setLevel(newLevel));\n  }\n\n  private static void ensureSupportedLevel(Level newLevel) {\n    if (!isAllowed(newLevel)) {\n      throw new IllegalArgumentException(format(\"%s log level is not supported (allowed levels are %s)\", newLevel, Arrays.toString(ALLOWED_ROOT_LOG_LEVELS)));\n    }\n  }\n\n  /**\n   * Creates a new {@link ConsoleAppender} to {@code System.out} with the specified name and log encoder.\n   */\n  public ConsoleAppender<ILoggingEvent> newConsoleAppender(Context loggerContext, String name, Encoder<ILoggingEvent> encoder) {\n    ConsoleAppender<ILoggingEvent> consoleAppender = new ConsoleAppender<>();\n    consoleAppender.setContext(loggerContext);\n    consoleAppender.setEncoder(encoder);\n    consoleAppender.setName(name);\n    consoleAppender.setTarget(\"System.out\");\n    consoleAppender.start();\n    return consoleAppender;\n  }\n\n  /**\n   * Make logback configuration for a process to push all its logs to a log file.","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java#L139-L175","documentation":"ensureSupportedLevel validates a logback root Level against ALLOWED_ROOT_LOG_LEVELS before LogbackHelper.applyChangeToRootLogger applies it. Logback defines levels beyond the allowed subset (TRACE, ALL, and custom levels), so an out-of-subset level is rejected with an IllegalArgumentException instead of silently misconfiguring logging.","triggerScenarios":"Calling changeRoot (directly or via the web API /admin/process logs or ws log level change) with a level such as ALL, TRACE, or a custom/invalid string parsed into a logback Level outside the allow-list.","commonSituations":"Attempting to enable TRACE/ALL debugging at runtime; a monitoring script POSTing an unsupported level name; property `sonar.log.level` mapped to a disallowed level.","solutions":["Use one of the allowed root levels only (typically TRACE, DEBUG, INFO, WARN, ERROR).","If you want maximum verbosity, use TRACE rather than ALL.","For per-logger configuration, ensure any property-configured level is also within the allow-list."],"exampleFix":"// before\nchangeRoot(Level.ALL);\n// after\nchangeRoot(Level.TRACE);","handlingStrategy":"validation","validationCode":"Set<String> allowed = Set.of(\"TRACE\", \"DEBUG\", \"INFO\", \"WARN\", \"ERROR\");\nString level = requested.toUpperCase(Locale.ROOT);\nif (!allowed.contains(level)) throw new IllegalArgumentException(\"Unsupported level: \" + level);\nchangeRoot(Level.toLevel(level));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict level-switching UIs/scripts to TRACE..ERROR.","Never send ALL or custom logback levels to the changeRoot API.","Prefer per-logger config for fine-grained verbosity."],"tags":["logging","log-level","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}