Migrating from log4j 1.x to 2.x

suggest change

If you want to migrate from existing log4j 1.x in your project to log4j 2.x, remove all existing log4j 1.x dependencies and add the following dependency. The bridge adapts the Log4j 1 API. A Log4j 2 implementation, usually log4j-core, still has to be on the classpath.

Log4j 1.x API Bridge

Maven Build

<dependencies>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-1.2-api</artifactId>
    <version>2.6.2</version>
  </dependency>
</dependencies>

Ivy Build

<dependencies>
  <dependency org="org.apache.logging.log4j" name="log4j-1.2-api" rev="2.6.2" />
</dependencies>

Gradle Build

dependencies {
  compile group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: '2.6.2'
}

Apache Commons Logging Bridge If your project is using Apache Commons Logging, which uses Log4j 1.x, and you want to migrate it to Log4j 2.x, add the following dependencies:

Maven Build

<dependencies>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-jcl</artifactId>
    <version>2.6.2</version>
  </dependency>
</dependencies>

Ivy Build

<dependencies>
  <dependency org="org.apache.logging.log4j" name="log4j-jcl" rev="2.6.2" />
</dependencies>

Gradle Build

dependencies {
  compile group: 'org.apache.logging.log4j', name: 'log4j-jcl', version: '2.6.2'
}

Note: Do not remove any existing dependencies of Apache Commons Logging.

Reference: https://logging.apache.org/log4j/2.x/maven-artifacts.html

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents