Migrate Log4j 1.x to Log4j 2.x

MSAL

Migrates Log4j 1.x to Log4j 2.x.

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

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 any Lombok log annotations with target logging framework annotation
  2. Change method target to static
  3. Change method target to static
  4. Convert Log4j Logger.setLevel to Log4j2 Configurator.setLevel
  5. Change method name org.apache.log4j.Priority isGreaterOrEqual(org.apache.log4j.Priority) to isMoreSpecificThan
  6. Change method name org.apache.log4j.Category isEnabledFor(org.apache.log4j.Priority) to isEnabled
  7. Change type Priority to Level
  8. Change method target to static
  9. Change method name org.apache.logging.log4j.LogManager getInstance(Class) to getLogger
  10. Change method name org.apache.log4j.Category getEffectiveLevel() to getLevel
  11. Change type Category to Logger
  12. Rename package name org.apache.log4j to org.apache.logging.log4j
  13. Parameterize Log4j 2.x logging statements
  14. Add Gradle or Maven dependency org.apache.logging.log4j:log4j-api:2.x
  15. Add Gradle or Maven dependency org.apache.logging.log4j:log4j-core:2.x
  16. Remove a Gradle or Maven dependency log4j:log4j
  17. Remove a Gradle or Maven dependency ch.qos.reload4j:reload4j
  18. Add Gradle or Maven dependency org.apache.logging.log4j:log4j-api:2.x
  19. Add Gradle or Maven dependency org.apache.logging.log4j:log4j-core:2.x
  20. Change Gradle or Maven dependency org.slf4j:slf4j-log4j12
  21. Change Gradle or Maven dependency org.slf4j:slf4j-reload4j
  22. Upgrade Log4j 2.x dependency version
  23. Inline log4j-api-2 methods annotated with @InlineMe