LOG4J2-2677: Rollover and Deletion handle file deletions gracefully

It's common for multiple appenders to write (and roll) log files
into a single directory. When these appenders are also responsible
for cleaning up after themselves, they must also search that
directory for files to delete. These searches are executed in
parallel by multiple appenders and have a chance to delete files
the other is checking before the file can be checked against
a regex or glob.
Missing files can safely be assumed to have been deleted.
5 files changed
tree: bca088374af9725455b35a22c3ba999013f3b03b
  1. .mvn/
  2. log4j-1.2-api/
  3. log4j-api/
  4. log4j-api-java9/
  5. log4j-appserver/
  6. log4j-bom/
  7. log4j-cassandra/
  8. log4j-core/
  9. log4j-core-its/
  10. log4j-core-java9/
  11. log4j-couchdb/
  12. log4j-csv/
  13. log4j-distribution/
  14. log4j-docker/
  15. log4j-flume-ng/
  16. log4j-iostreams/
  17. log4j-jcl/
  18. log4j-jdbc/
  19. log4j-jdbc-dbcp2/
  20. log4j-jeromq/
  21. log4j-jms/
  22. log4j-jmx-gui/
  23. log4j-jpa/
  24. log4j-jul/
  25. log4j-kafka/
  26. log4j-kubernetes/
  27. log4j-layout-jackson/
  28. log4j-layout-jackson-json/
  29. log4j-layout-jackson-xml/
  30. log4j-layout-jackson-yaml/
  31. log4j-liquibase/
  32. log4j-mongodb2/
  33. log4j-mongodb3/
  34. log4j-osgi/
  35. log4j-perf/
  36. log4j-plugins/
  37. log4j-plugins-java9/
  38. log4j-samples/
  39. log4j-slf4j-impl/
  40. log4j-slf4j18-impl/
  41. log4j-smtp/
  42. log4j-spring-cloud-config/
  43. log4j-taglib/
  44. log4j-to-slf4j/
  45. log4j-web/
  46. src/
  47. .dockerignore
  48. .gitattributes
  49. .gitignore
  50. .travis-toolchains.xml
  51. .travis.yml
  52. BUILDING.md
  53. checkstyle-header.txt
  54. checkstyle-import-control.xml
  55. checkstyle-suppressions.xml
  56. checkstyle.xml
  57. CONTRIBUTING.md
  58. Dockerfile
  59. Jenkinsfile
  60. LICENSE.txt
  61. mvnw
  62. mvnw.cmd
  63. NOTICE.txt
  64. pom.xml
  65. README.md
  66. RELEASE-NOTES.md
  67. spotbugs-exclude-filter.xml
  68. toolchains-docker.xml
  69. toolchains-jenkins-ibm.xml
  70. toolchains-jenkins-ubuntu.xml
  71. toolchains-jenkins-win.xml
  72. toolchains-sample-linux.xml
  73. toolchains-sample-mac.xml
  74. toolchains-sample-win.xml
README.md

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

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