apache/beam · error · IllegalArgumentException
Unsupported log level
Error message
Unsupported log level: {level} What it means
LogElements.log dispatches on the configured Level; if the level is not one of TRACE..ERROR it throws IllegalArgumentException('Unsupported log level: ' + level). Only the five standard levels are accepted.
Solutions
- Pass one of Level.TRACE, DEBUG, INFO, WARN, or ERROR.
- Validate/map custom levels before calling log(); default unexpected values to INFO.
- Null-check the level and substitute a safe default.
Example fix
// before LogElements.log(myLevel, msg); // myLevel may be custom/null // after Level lvl = (myLevel == null) ? Level.INFO : myLevel; LogElements.log(lvl, msg);
Defensive patterns
Strategy: validation
Validate before calling
private static final Set<Level> ALLOWED = EnumSet.of(Level.TRACE, Level.DEBUG, Level.INFO, Level.WARN, Level.ERROR); if (level == null || !ALLOWED.contains(level)) level = Level.INFO;
Type guard
static boolean isSupportedLogLevel(Level l) {
return l != null && (l == Level.TRACE || l == Level.DEBUG || l == Level.INFO || l == Level.WARN || l == Level.ERROR);
} Try / catch
try {
LogElements.log(level, msg);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unsupported log level")) {
LogElements.log(Level.INFO, msg);
}
} Prevention
- Map custom log levels to the five standard Levels before use.
- Validate pipeline options parsing for log level strings.
- Default null/unknown levels to INFO.
When it happens
Trigger: Calling LogElements.log(level, ...) or withLevel with null, a custom Level (e.g. FATAL), or an unknown enum value.
Common situations: Mapping an application-level log enum to Beam's Level and falling through with a default; passing a level parsed from config that is out of range; passing null.
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
- " " argument must be specified.
- " " argument must be specified, Valid values are
- Batch size is too large! It should be smaller or equal than
- BigQuery %1$s not found for table "%2$s" . Please create…
- Both clientCertPath and clientCertKeyPath must be specified…
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/3faee46fc7ceef3b.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/LogElements.java:171
static void log(Level level, String message) {
switch (level) {
case TRACE:
LOG.trace("{}", message);
break;
case DEBUG:
LOG.debug("{}", message);
break;
case INFO:
LOG.info("{}", message);
break;
case WARN:
LOG.warn("{}", message);
break;
case ERROR:
LOG.error("{}", message);
break;
default:
throw unsupportedLogLevel(level);
}
}
private static boolean isLoggingEnabled(Level level) {
switch (level) {
case TRACE:
return LOG.isTraceEnabled();
case DEBUG:
return LOG.isDebugEnabled();
case INFO:
return LOG.isInfoEnabled();
case WARN:
return LOG.isWarnEnabled();
case ERROR:
return LOG.isErrorEnabled();
default:
throw unsupportedLogLevel(level);
}View on GitHub (pinned to 12126d8942)