SonarSource/sonarqube · error · IllegalArgumentException

log level in property is not a supported value (allowed…

Error message

log level %s in property %s is not a supported value (allowed levels are %s)

What it means

AbstractLogHelper.getPropertyValueAsLevel reads a logging level property and converts it with Log4j Level.toLevel (defaulting to INFO when unparseable). If the resulting level is not among ALLOWED_ROOT_LOG_LEVELS, it throws IllegalArgumentException listing the allowed levels.

Solutions

  1. Set the property to one of the allowed levels: TRACE, DEBUG, INFO, WARN, ERROR.
  2. Replace unsupported synonyms (e.g. WARNING -> WARN, FATAL -> ERROR, VERBOSE -> DEBUG).
  3. Trim whitespace and check casing if the value looks correct but still rejected.

Example fix

// before
sonar.log.level=warning
// after
sonar.log.level=WARN
Defensive patterns

Strategy: validation

Validate before calling

Set<String> ALLOWED = Set.of("TRACE", "DEBUG", "INFO", "WARN", "ERROR");
String lvl = props.value("sonar.log.level");
if (lvl != null && !ALLOWED.contains(lvl.trim().toUpperCase(Locale.ROOT))) {
  throw new IllegalStateException("sonar.log.level must be one of " + ALLOWED + ", got: " + lvl);
}

Try / catch

try {
  Level level = logHelper.getPropertyValueAsLevel("sonar.log.level");
} catch (IllegalArgumentException e) {
  logger.error("Invalid log level config: {}", e.getMessage());
  // fall back to INFO
}

Prevention

When it happens

Trigger: Setting sonar.log.level (or a per-process log level property like sonar.web.logLevel) to a value outside the allowed set (TRACE, DEBUG, INFO, WARN, ERROR), e.g. "verbose", "warning", or "FATAL".

Common situations: Users copying log level names from other frameworks (logback/Jul "warning", "fatal") into sonar.properties; mixed-case or padded values; changing log level at runtime via web API with a bad value.

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 SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/87e69654a34fa2ac. Report an issue: GitHub.

Appendix: source

Thrown at server/sonar-process/src/main/java/org/sonar/process/logging/AbstractLogHelper.java:81

    for (String propertyKey : propertyKeys) {
      Level level = getPropertyValueAsLevel(props, propertyKey);
      if (level != null) {
        newLevel = level;
      }
    }
    return newLevel;
  }

  @CheckForNull
  static Level getPropertyValueAsLevel(Props props, String propertyKey) {
    String value = props.value(propertyKey);
    if (value == null) {
      return null;
    }

    Level level = Level.toLevel(value, Level.INFO);
    if (!isAllowed(level)) {
      throw new IllegalArgumentException(format("log level %s in property %s is not a supported value (allowed levels are %s)",
        level, propertyKey, Arrays.toString(ALLOWED_ROOT_LOG_LEVELS)));
    }
    return level;
  }

  static boolean isAllowed(Level level) {
    for (Level allowedRootLogLevel : ALLOWED_ROOT_LOG_LEVELS) {
      if (level.equals(allowedRootLogLevel)) {
        return true;
      }
    }
    return false;
  }
}

View on GitHub (pinned to 184c821202)