user avatar
[LOG4J2-2114] Provide a native Log4j 2 implementation of Eclipse Jetty's
Gary Gregory authored
org.eclipse.jetty.util.log.Logger. Javadoc.
d85f39ab
Name Last commit Last update
.mvn/wrapper Add missing license headers
log4j-1.2-api LOG4J2-2098 - Add a noop AppenderSkeleton for applications still using Log4j 1.x
log4j-api-java9 LOG4J-2056 - modularize log4j-api. Turn others into automatic modules
log4j-api Fix MapMessageTest
log4j-appserver [LOG4J2-2114] Provide a native Log4j 2 implementation of Eclipse Jetty's
log4j-bom LOG4J2-2076 CouchDB and MongoDB appenders in own modules, remove log4j-nosql module
log4j-cassandra LOG4J2-2076 Rename packages
log4j-core-its The next version will be 2.10.0.
log4j-core LOG4J2-2106 - Revert changes
log4j-couchdb LOG4J2-2076 Rename packages
log4j-distribution LOG4J2-2076 CouchDB and MongoDB appenders in own modules, remove log4j-nosql module
log4j-flume-ng LOG4J-2056 - modularize log4j-api. Turn others into automatic modules
log4j-iostreams LOG4J-2056 - modularize log4j-api. Turn others into automatic modules
log4j-jcl LOG4J-2056 - modularize log4j-api. Turn others into automatic modules
log4j-jmx-gui LOG4J-2056 - modularize log4j-api. Turn others into automatic modules
log4j-jul LOG4J-2056 - modularize log4j-api. Turn others into automatic modules
log4j-liquibase LOG4J-2056 - modularize log4j-api. Turn others into automatic modules
log4j-mongodb LOG4J2-2076 Rename packages
log4j-osgi LOG4J-2056 - modularize log4j-api. Turn others into automatic modules
log4j-perf The next version will be 2.10.0.
log4j-samples The next version will be 2.10.0.
log4j-slf4j-impl LOG4J-2056 - modularize log4j-api. Turn others into automatic modules
log4j-taglib [LOG4J2-2089][TagLib] Update servlet-api provided dependency from 2.5 to
log4j-to-slf4j LOG4J-2056 - modularize log4j-api. Turn others into automatic modules
log4j-web LOG4J2-2091: Respect the configured "log4j2.is.webapp" property
src
.dockerignore
.gitattributes
.gitignore
.travis-toolchains.xml
.travis.yml
BUILDING.md
CONTRIBUTING.md
Dockerfile
LICENSE.txt
NOTICE.txt
README.md
RELEASE-NOTES.md
checkstyle-header.txt
checkstyle-import-control.xml
checkstyle-suppressions.xml
checkstyle.xml
doap_log4j2.rdf
findbugs-exclude-filter.xml
jenkins-toolchains.xml
mvnw
mvnw.cmd
pom.xml
toolchains-docker.xml
toolchains-sample-linux.xml
toolchains-sample-mac.xml
toolchains-sample-win.xml

Apache Log4j 2

Apache Log4j 2 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in Logback's architecture.

Jenkins Status Travis Status Maven Central

Usage

Users should refer to Maven, Ivy, Gradle, and SBT Artifacts on the Log4j web site for instructions on how to include Log4j into their project using their chosen build tool.

Basic usage of the Logger API:

package com.example;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;

public class Example {
    private static final Logger LOGGER = LogManager.getLogger();

    public static void main(String... args) {
        String thing = args.length > 0 ? args[0] : "world";
        LOGGER.info("Hello, {}!", thing);
        LOGGER.debug("Got calculated value only if debug enabled: {}", () -> doSomeCalculation());
    }

    private static Object doSomeCalculation() {
        // do some complicated calculation
    }
}

And an example log4j2.xml configuration file:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
  <Appenders>
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
  </Appenders>
  <Loggers>
    <Logger name="com.example" level="INFO"/>
    <Root level="error">
      <AppenderRef ref="Console"/>
    </Root>
  </Loggers>
</Configuration>

Documentation

The Log4j 2 User's Guide is available here or as a downloadable PDF.

Requirements

Log4j 2.4 and greater requires Java 7, versions 2.0-alpha1 to 2.3 required Java 6. Some features require optional dependencies; the documentation for these features specifies the dependencies.

License

Apache Log4j 2 is distributed under the Apache License, version 2.0.

Download

How to download Log4j, and how to use it from Maven, Ivy and Gradle. You can access the latest development snapshot by using the Maven repository https://repository.apache.org/snapshots, see Snapshot builds.

Issue Tracking

Issues, bugs, and feature requests should be submitted to the JIRA issue tracking system for this project.

Pull request on GitHub are welcome, but please open a ticket in the JIRA issue tracker first, and mention the JIRA issue in the Pull Request.

Building From Source

Log4j requires Apache Maven 3.x. To build from source and install to your local Maven repository, execute the following:

mvn install

Contributing

We love contributions! Take a look at our contributing page.