"git@git.gitsec.cn:lixiaofang/logging-log4j2.git" did not exist on "e6ce8e4e137f00e9c3ab2f341dfda03c1f76a88a"
Name Last commit Last update
.mvn/wrapper Add missing license headers
log4j-1.2-api [maven-release-plugin] prepare for next development iteration
log4j-api-scala_2.10 [maven-release-plugin] prepare for next development iteration
log4j-api-scala_2.11 [maven-release-plugin] prepare for next development iteration
log4j-api LOG4J2-1359 - Java 9 support
log4j-bom [maven-release-plugin] prepare for next development iteration
log4j-core-its LOG4J2-1359 - Remove profiles
log4j-core LOG4J2-1359 - Ignore javadoc problems in core due to Java 9 classes. Modify build instructions
log4j-distribution [maven-release-plugin] prepare for next development iteration
log4j-flume-ng [maven-release-plugin] prepare for next development iteration
log4j-iostreams [maven-release-plugin] prepare for next development iteration
log4j-java9 LOG4J2-1359 - Remove profiles
log4j-jcl [maven-release-plugin] prepare for next development iteration
log4j-jmx-gui [maven-release-plugin] prepare for next development iteration
log4j-jul [maven-release-plugin] prepare for next development iteration
log4j-liquibase [maven-release-plugin] prepare for next development iteration
log4j-nosql [LOG4J2-1850]: Fix Cassandra unit tests on Windows
log4j-osgi [maven-release-plugin] prepare for next development iteration
log4j-perf Add Jenkins toolchain. Create benchmarks
log4j-samples [maven-release-plugin] prepare for next development iteration
log4j-slf4j-impl LOG4J2-1359 - Remove profiles
log4j-taglib [maven-release-plugin] prepare for next development iteration
log4j-to-slf4j LOG4J2-1836 - Update the API version
log4j-web [maven-release-plugin] prepare for next development iteration
src LOG4J2-1359 - Ignore javadoc problems in core due to Java 9 classes. Modify build instructions
.dockerignore
.gitattributes
.gitignore
.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-sample.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](https://builds.apache.org/buildStatus/icon?job=Log4j 2.x) Travis Status Coverage Status

Usage

Maven users can add the following dependencies to their pom.xml file:

<dependencies>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.8</version>
  </dependency>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.8</version>
  </dependency>
</dependencies>

Gradle users can add the following to their build.gradle file:

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

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.

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.