stanfordnlp/CoreNLP · error · IllegalStateException

Unknown Redwood flag for slf4j integration:

Error message

Unknown Redwood flag for slf4j integration: 

What it means

SLF4JHandler.print() maps the target flag (loggerAndLevel.second) to an SLF4J logger level call; a value outside the known set (not FORCE/STDOUT/STDERR etc.) throws this IllegalStateException, so unknown/unsupported Redwood flags are rejected.

Solutions

  1. Only use SLF4JHandler via supported factory/configuration paths (Handlers.slf4j, documented constructors).
  2. Log/inspect the offending flag value in the message and map it to a supported one.
  3. Ensure all Redwood jars on the classpath are the same version to avoid mismatched flag enums.
  4. Route unknown targets through Handlers.output instead.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  config.handlers(Handlers.slf4j).apply();
} catch (IllegalStateException e) {
  if (e.getMessage().startsWith("Unknown Redwood flag for slf4j integration:")) {
    log.error("Unrecognized SLF4JHandler target flag; check jar versions", e);
    RedwoodConfiguration.empty().handlers(Handlers.output).apply();
  } else throw e;
}

Prevention

When it happens

Trigger: An SLF4JHandler constructed or configured with a target flag value not recognized by its switch — typically from custom code or a modified handler passing an arbitrary Object as the level/target.

Common situations: Custom integrations feeding SLF4JHandler with bespoke flags; mismatched library versions where a new flag was added to one class but not the other; reflection-based manipulation of handler internals.

Understand the failure class

Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/dd8ea126d762415e. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/util/logging/SLF4JHandler.java:93

    // Route the signal
    switch (loggerAndLevel.second) {
      case ERROR:
        loggerAndLevel.first.error(line);
        break;
      case WARN:
        loggerAndLevel.first.warn(line);
        break;
      case DEBUG:
        loggerAndLevel.first.debug(line);
        break;
      case STDOUT:
      case STDERR:
        loggerAndLevel.first.info(line);
        break;
      case FORCE:
        throw new IllegalStateException("Should not reach this switch case");
      default:
        throw new IllegalStateException("Unknown Redwood flag for slf4j integration: " + loggerAndLevel.second);
    }
  }

}

View on GitHub (pinned to 1b7edd19c4)