Skip to content

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.

License

Notifications You must be signed in to change notification settings

baoping88/logging-log4j2

This branch is 1479 commits ahead of, 4464 commits behind apache/logging-log4j2:2.x.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c2b07e3 · Dec 9, 2021
Dec 8, 2021
Jul 2, 2020
Dec 5, 2021
Nov 16, 2021
Jul 29, 2021
Sep 20, 2020
Oct 24, 2021
Oct 24, 2021
Dec 9, 2021
Apr 9, 2021
Oct 24, 2021
Aug 13, 2020
Jul 29, 2021
Nov 20, 2021
Oct 24, 2021
Oct 24, 2021
Nov 24, 2021
Oct 24, 2021
Oct 24, 2021
Oct 24, 2021
Oct 24, 2021
Dec 5, 2021
Jun 24, 2021
Oct 24, 2021
Oct 24, 2021
Nov 15, 2021
Oct 24, 2021
Oct 24, 2021
Dec 6, 2021
Oct 24, 2021
Oct 24, 2021
Jul 29, 2021
Nov 8, 2021
Oct 24, 2021
Oct 24, 2021
Oct 24, 2021
Oct 24, 2021
Dec 6, 2021
Oct 24, 2021
Oct 24, 2021
Nov 6, 2020
Oct 24, 2021
Oct 24, 2021
Nov 16, 2021
Dec 6, 2021
Nov 22, 2021
Oct 24, 2021
Oct 24, 2021
Oct 24, 2021
Dec 6, 2021
Jul 26, 2020
Jan 29, 2017
Feb 13, 2017
Jul 2, 2020
Jul 26, 2020
Jan 29, 2017
Jul 26, 2020
Mar 25, 2012
Jun 8, 2019
Aug 21, 2021
Jan 29, 2018
Aug 23, 2020
Sep 6, 2011
Jul 7, 2013
Sep 29, 2014
Sep 24, 2015
Jul 2, 2020
Jul 2, 2020
Dec 5, 2021
Feb 17, 2018
Jul 26, 2020
Aug 15, 2020
Aug 15, 2020
Aug 15, 2020

Repository files navigation

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 build (3.x) Jenkins build (2.x) GitHub build (3.x) GitHub build (2.x) Latest Maven Central release

Pull Requests on Github

By sending a pull request you grant the Apache Software Foundation sufficient rights to use and release the submitted work under the Apache license. You grant the same rights (copyright license, patent license, etc.) to the Apache Software Foundation as if you have signed a Contributor License Agreement. For contributions that are judged to be non-trivial, you will be asked to actually sign a Contributor License Agreement.

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 requests 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.

About

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.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 99.9%
  • Other 0.1%