Replace Log4j 2.x active Level check with corresponding SLF4J method calls

MSAL

Replace calls to Logger.isEnabled(Level) with the corresponding SLF4J method calls.

org.openrewrite.java.logging.slf4j.Log4j2IsEnabledToSlf4jRecipes
mod run . --recipe=org.openrewrite.java.logging.slf4j.Log4j2IsEnabledToSlf4jRecipes

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Replace Log4j 2.x Logger.isEnabled(Level.TRACE) with SLF4J's Logger.isTraceEnabled()
  2. Replace Log4j 2.x Logger.isEnabled(Level.DEBUG) with SLF4J's Logger.isDebugEnabled()
  3. Replace Log4j 2.x Logger.isEnabled(Level.INFO) with SLF4J's Logger.isInfoEnabled()
  4. Replace Log4j 2.x Logger.isEnabled(Level.WARN) with SLF4J's Logger.isWarnEnabled()
  5. Replace Log4j 2.x Logger.isEnabled(Level.ERROR) with SLF4J's Logger.isErrorEnabled()