blob: 7128bc22ed0b7a57ed51ceeb61f7d40f7376c662 [file] [log] [blame]
<!-- vim: set syn=markdown : -->
<!--
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.
-->
<!-- TODO: turn this into a velocity template for all the version numbers -->
#set($h1 = '#')
#set($h2 = '##')
#set($h3 = '###')
#set($h4 = '####')
$h1 Application Server Integration
The Application Server module provides support for integrating Log4j into various Java Application Servers.
$h2 Apache Tomcat
Log4j may be used as the logging framework for Apache Tomcat. This support is implemented automatically by including
the log4j-api, log4j-core, and log4j-appserver jars in the boot classpath. A file named log4j2-tomcat.xml,
log4j2-tomcat.json, log4j2-tomcat.yaml, log4j2-tomcat.yml, or log4j2-tomcat.properties must also be placed
in the boot classpath. This is most easily done by:
1. Creating a set of directories in catalina home named log4j2/lib and log4j2/conf.
2. Placing log4j2-api-${Log4jReleaseVersion}.jar, log4j2-core-${Log4jReleaseVersion}.jar, and
log4j2-appserver-${Log4jReleaseVersion}.jar in the log4j2/lib directory.
3. Creating a file named log4j2-tomcat.xml, log4j2-tomcat.json, log4j2-tomcat.yaml, log4j2-tomcat.yml, or
log4j2-tomcat.properties in the log4j2/conf directory.
4. Create or modify setenv.sh in the tomcat bin directory to include
```CLASSPATH=$CATALINA_HOME/log4j2/lib/*:$CATALINA_HOME/log4j2/conf```
$h3 Requirements
Requires Tomcat 8.5 or later.
$h2 Eclipse Jetty
Log4j may be used as the logging framework for Eclipse Jetty.
To direct Jetty to use this class, set the system property `org.eclipse.jetty.util.log.class` to `org.apache.logging.log4j.appserver.jetty.Log4j2Logger`.
From the command line with:
```-Dorg.eclipse.jetty.util.log.class = org.apache.logging.log4j.appserver.jetty.Log4j2Logger```
Programmatically with:
```System.setProperty("org.eclipse.jetty.util.log.class", "org.apache.logging.log4j.appserver.jetty.Log4j2Logger");```