Apache logging services logo Apache log4j logo

Maven and Ivy Artifacts

Using Log4j in your Apache Maven build

To build with Apache Maven, add the dependencies listed below to your pom.xml file.

pom.xml
<dependencies>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.0-rc1</version>
  </dependency>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.0-rc1</version>
  </dependency>
</dependencies>

Using Log4j in your Apache Ivy build

To build with Apache Ivy, add the dependencies listed below to your ivy.xml file.

ivy.xml
<dependencies>
  <dependency org="org.apache.logging.log4j" name="log4j-api" rev="2.0-rc1" />
  <dependency org="org.apache.logging.log4j" name="log4j-core" rev="2.0-rc1" />
</dependencies>

Optional Components

Log4j 2.x contains several optional components that can be included in an application.

Log4j 1.x API Bridge

If existing components use Log4j 1.x and you want to have this logging routed to Log4j 2, then remove any log4j 1.x dependencies and add the following.

pom.xml
<dependencies>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-1.2-api</artifactId>
    <version>2.0-rc1</version>
  </dependency>
</dependencies>
ivy.xml
<dependencies>
  <dependency org="org.apache.logging.log4j" name="log4j-1.2-api" rev="2.0-rc1" />
</dependencies>

Apache Commons Logging Bridge

If existing components use Apache Commons Logging 1.x and you want to have this logging routed to Log4j 2, then add the following but do not remove any Commons Logging 1.x dependencies.

pom.xml
<dependencies>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-jcl</artifactId>
    <version>2.0-rc1</version>
  </dependency>
</dependencies>
ivy.xml
<dependencies>
  <dependency org="org.apache.logging.log4j" name="log4j-jcl" rev="2.0-rc1" />
</dependencies>

SLF4J Bridge

If existing components use SLF4J and you want to have this logging routed to Log4j 2, then add the following but do not remove any SLF4J dependencies.

pom.xml
<dependencies>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-slf4j-impl</artifactId>
    <version>2.0-rc1</version>
  </dependency>
</dependencies>
ivy.xml
<dependencies>
  <dependency org="org.apache.logging.log4j" name="log4j-slf4j-impl" rev="2.0-rc1" />
</dependencies>

Tag Library

The Log4j Log Tag Library creates the capability of inserting log statements in JSPs without the use of Java scripting. It uses the standard Log4j 2 API to log messages according to your Log4j configuration.

pom.xml
<dependencies>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-taglib</artifactId>
    <version>2.0-rc1</version>
  </dependency>
</dependencies>
ivy.xml
<dependencies>
  <dependency org="org.apache.logging.log4j" name="log4j-taglib" rev="2.0-rc1" />
</dependencies>

Apache Flume NG Appender

The Flume NG Appender allows applications to send events to Flume NG Agents.

pom.xml
<dependencies>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-flume-ng</artifactId>
    <version>2.0-rc1</version>
  </dependency>
</dependencies>
ivy.xml
<dependencies>
  <dependency org="org.apache.logging.log4j" name="log4j-flume-ng" rev="2.0-rc1" />
</dependencies>

Log4j to SLF4J Adapter

The Log4j 2 to SLF4J Adapter allows applications coded to the Log4j 2 API to be routed to SLF4J. Use of this adapter may cause some loss of performance as the Log4j 2 Messages must be formatted before they can be passed to SLF4J. The SLF4J Bridge must NOT be on the class path when this is in use.

pom.xml
<dependencies>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-to-slf4j</artifactId>
    <version>2.0-rc1</version>
  </dependency>
</dependencies>
ivy.xml
<dependencies>
  <dependency org="org.apache.logging.log4j" name="log4j-to-slf4j" rev="2.0-rc1" />
</dependencies>