blob: 739b831fdd4cde0adab8f0a8b176453bdfd9b2d8 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
<properties>
<title>Maven, Ivy, and Gradle Artifacts</title>
</properties>
<body>
<section name="Maven, Ivy, and Gradle Artifacts">
<subsection name="Using Log4j in your Apache Maven build">
<p>
To build with <a href="http://maven.apache.org/">Apache Maven</a>, add the dependencies listed below to your
<code>pom.xml</code> file.
</p>
<code>pom.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${Log4jReleaseVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${Log4jReleaseVersion}</version>
</dependency>
</dependencies>
]]></pre>
</subsection>
<subsection name="Using Log4j in your Apache Ivy build">
<p>
To build with <a href="https://ant.apache.org/ivy/">Apache Ivy</a>, add the dependencies listed below to your
<code>ivy.xml</code> file.
</p>
<code>ivy.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency org="org.apache.logging.log4j" name="log4j-api" rev="${Log4jReleaseVersion}" />
<dependency org="org.apache.logging.log4j" name="log4j-core" rev="${Log4jReleaseVersion}" />
</dependencies>
]]></pre>
</subsection>
<subsection name="Using Log4j in your Gradle build">
<p>
To build with <a href="http://www.gradle.org/">Gradle</a>, add the dependencies listed below to your
<code>build.gradle</code> file.
</p>
<code>build.gradle</code>
<pre class="prettyprint linenums"><![CDATA[
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '${Log4jReleaseVersion}'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '${Log4jReleaseVersion}'
}
]]></pre>
</subsection>
<subsection name="Bill of Material">
<p>
To keep your Log4j module versions in sync with each other, a
<abbr id="Bill of Material">BOM</abbr>
pom.xml file is provided for your convenience. To use this with
<a href="http://maven.apache.org/">Maven</a>, add the dependency listed below to your
<code>pom.xml</code>
file. When you specify the version identifier in this section, you don't have to specify the version in your
<code><![CDATA[<dependencies/>]]></code>
section.
</p>
<code>pom.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>${Log4jReleaseVersion}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
]]></pre>
</subsection>
<subsection name="Optional Components">
<p>
Log4j 2.x contains several optional components that can be included in an application.
</p>
<h4>Log4j 1.x API Bridge</h4>
<p>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.
</p>
<code>pom.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>${Log4jReleaseVersion}</version>
</dependency>
</dependencies>
]]></pre>
<code>ivy.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency org="org.apache.logging.log4j" name="log4j-1.2-api" rev="${Log4jReleaseVersion}" />
</dependencies>
]]></pre>
<code>build.gradle</code>
<pre class="prettyprint linenums"><![CDATA[
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: '${Log4jReleaseVersion}'
}
]]></pre>
<h4>Apache Commons Logging Bridge</h4>
<p>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.
</p>
<code>pom.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>${Log4jReleaseVersion}</version>
</dependency>
</dependencies>
]]></pre>
<code>ivy.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency org="org.apache.logging.log4j" name="log4j-jcl" rev="${Log4jReleaseVersion}" />
</dependencies>
]]></pre>
<code>build.gradle</code>
<pre class="prettyprint linenums"><![CDATA[
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-jcl', version: '${Log4jReleaseVersion}'
}
]]></pre>
<h4>SLF4J Bridge</h4>
<p>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.
</p>
<code>pom.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${Log4jReleaseVersion}</version>
</dependency>
</dependencies>
]]></pre>
<code>ivy.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency org="org.apache.logging.log4j" name="log4j-slf4j-impl" rev="${Log4jReleaseVersion}" />
</dependencies>
]]></pre>
<code>build.gradle</code>
<pre class="prettyprint linenums"><![CDATA[
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '${Log4jReleaseVersion}'
}
]]></pre>
<h4>Web Servlet Support</h4>
<p>
In order to properly support and handle the ClassLoader environment and container lifecycle of a web
application, an additional module is required. This module is only required at runtime. In addition, if
you're using servlets in an OSGi environment, make sure your preferred version of the servlet API is
already available (e.g., if you want to use 3.0, but you've also got 2.5 loaded, make sure both are
loaded).
</p>
<code>pom.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>${Log4jReleaseVersion}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
]]></pre>
<code>ivy.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency org="org.apache.logging.log4j" name="log4j-web" rev="${Log4jReleaseVersion}" />
</dependencies>
]]></pre>
<code>build.gradle</code>
<pre class="prettyprint linenums"><![CDATA[
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-web', version: '${Log4jReleaseVersion}'
}
]]></pre>
<h4>Tag Library</h4>
<p>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.
</p>
<code>pom.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-taglib</artifactId>
<version>${Log4jReleaseVersion}</version>
</dependency>
</dependencies>
]]></pre>
<code>ivy.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency org="org.apache.logging.log4j" name="log4j-taglib" rev="${Log4jReleaseVersion}" />
</dependencies>
]]></pre>
<code>build.gradle</code>
<pre class="prettyprint linenums"><![CDATA[
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-taglib', version: '${Log4jReleaseVersion}'
}
]]></pre>
<h4>Apache Flume NG Appender</h4>
<p>The Flume NG Appender allows applications to send events to Flume NG Agents.</p>
<code>pom.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-flume-ng</artifactId>
<version>${Log4jReleaseVersion}</version>
</dependency>
</dependencies>
]]></pre>
<code>ivy.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency org="org.apache.logging.log4j" name="log4j-flume-ng" rev="${Log4jReleaseVersion}" />
</dependencies>
]]></pre>
<code>build.gradle</code>
<pre class="prettyprint linenums"><![CDATA[
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-flume-ng', version: '${Log4jReleaseVersion}'
}
]]></pre>
<h4>Log4j to SLF4J Adapter</h4>
<p>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.</p>
<code>pom.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>${Log4jReleaseVersion}</version>
</dependency>
</dependencies>
]]></pre>
<code>ivy.xml</code>
<pre class="prettyprint linenums"><![CDATA[
<dependencies>
<dependency org="org.apache.logging.log4j" name="log4j-to-slf4j" rev="${Log4jReleaseVersion}" />
</dependencies>
]]></pre>
<code>build.gradle</code>
<pre class="prettyprint linenums"><![CDATA[
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j', version: '${Log4jReleaseVersion}'
}
]]></pre>
</subsection>
</section>
</body>
</document>