Migrate Log4j 1.x MDC to SLF4J MDC

MSAL

Migrates org.apache.log4j.MDC to org.slf4j.MDC, wrapping non-String put values in String.valueOf(...) and converting getContext() to getCopyOfContextMap().

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

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. Wrap Log4j 1.x MDC.put values in String.valueOf(...)
  2. Convert Log4j 1.x MDC.getContext() to getCopyOfContextMap()
  3. Change type org.apache.log4j.MDC to org.slf4j.MDC