{"record":{"id":"3faee46fc7ceef3b","repo":"apache/beam","slug":"unsupported-log-level-level","errorCode":null,"errorMessage":"Unsupported log level: {level}","messagePattern":"Unsupported log level: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/LogElements.java","lineNumber":171,"sourceCode":"  static void log(Level level, String message) {\n    switch (level) {\n      case TRACE:\n        LOG.trace(\"{}\", message);\n        break;\n      case DEBUG:\n        LOG.debug(\"{}\", message);\n        break;\n      case INFO:\n        LOG.info(\"{}\", message);\n        break;\n      case WARN:\n        LOG.warn(\"{}\", message);\n        break;\n      case ERROR:\n        LOG.error(\"{}\", message);\n        break;\n      default:\n        throw unsupportedLogLevel(level);\n    }\n  }\n\n  private static boolean isLoggingEnabled(Level level) {\n    switch (level) {\n      case TRACE:\n        return LOG.isTraceEnabled();\n      case DEBUG:\n        return LOG.isDebugEnabled();\n      case INFO:\n        return LOG.isInfoEnabled();\n      case WARN:\n        return LOG.isWarnEnabled();\n      case ERROR:\n        return LOG.isErrorEnabled();\n      default:\n        throw unsupportedLogLevel(level);\n    }","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/LogElements.java#L153-L189","documentation":"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.","triggerScenarios":"Calling LogElements.log(level, ...) or withLevel with null, a custom Level (e.g. FATAL), or an unknown enum value.","commonSituations":"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.","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."],"exampleFix":"// before\nLogElements.log(myLevel, msg); // myLevel may be custom/null\n// after\nLevel lvl = (myLevel == null) ? Level.INFO : myLevel;\nLogElements.log(lvl, msg);","handlingStrategy":"validation","validationCode":"private static final Set<Level> ALLOWED = EnumSet.of(Level.TRACE, Level.DEBUG, Level.INFO, Level.WARN, Level.ERROR);\nif (level == null || !ALLOWED.contains(level)) level = Level.INFO;","typeGuard":"static boolean isSupportedLogLevel(Level l) {\n  return l != null && (l == Level.TRACE || l == Level.DEBUG || l == Level.INFO || l == Level.WARN || l == Level.ERROR);\n}","tryCatchPattern":"try {\n  LogElements.log(level, msg);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unsupported log level\")) {\n    LogElements.log(Level.INFO, msg);\n  }\n}","preventionTips":["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."],"tags":["java","logging","validation","beam-core"],"backgroundTag":"invalid-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}