codegenomeproject
Search
MarketplaceModules
PackagesCLIMCP
Sign in
  1. Marketplace
  2. Java
  3. Logging
  4. Migrate SLF4J to Log4j 2.x API

Migrate SLF4J to Log4j 2.x API

MSAL

Transforms code written using SLF4J to use Log4j 2.x API.

org.openrewrite.java.logging.log4j.Slf4jToLog4j
mod run . --recipe=org.openrewrite.java.logging.log4j.Slf4jToLog4j

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.

Recipe
  1. Change method target to static
  2. Change method target to static
  3. Change method target to static
  4. Change method name org.apache.logging.log4j.CloseableThreadContext putCloseable(..) to put
  5. Change method target to static
  6. Change method name org.apache.logging.log4j.ThreadContext clear(..) to clearAll
  7. Change method target to static
  8. Change method target to static
  9. Change method target to static
  10. Change method name org.slf4j.spi.LoggingEventBuilder addMarker(..) to withMarker
  11. Change method name org.slf4j.spi.LoggingEventBuilder setCause(..) to withThrowable
  12. Change type org.slf4j.Logger to org.apache.logging.log4j.Logger
  13. Change type org.slf4j.event.Level to org.apache.logging.log4j.Level
  14. Change type LoggingEventBuilder to LogBuilder
  15. Change type org.slf4j.Marker to org.apache.logging.log4j.Marker
  16. Change type MDCCloseable to CloseableThreadContext$Instance
  17. Change type MDC to CloseableThreadContext
  18. Change Gradle or Maven dependency org.slf4j:slf4j-api
  19. Replace any Lombok log annotations with target logging framework annotation
  20. Add imports for fully qualified references to types
© Moderne, 2026
Recipe indexPrivacyTerms