LOG4J2-2966 Revert the usage of ParameterizedMessage.deepToString().

There are a couple of motivations for me to revert this change, but
some particular highlights are as follows:

- Many of the type check that is performed by deepToString() is
  already addressed in JsonWriter.

- Usage of an external method breaks the self-containment contract of
  JsonWriter.

- deepToString() protects against recursive collections, whereas
  JsonWriter doesn't. Even using deepToString() in JsonWriter
  isn't enough to protect it against self-referencing collections;
  all collection handling methods in JsonWriter needs to be adapted.
  Hence, rather than a code base where there is partial mitigation for
  this anomaly, now it is explicit that there is no built-in prevention
  mechanisms. This behaviour is also in line with the Java standard
  library, e.g., Arrays.toString().
6 files changed
tree: 2cf8d50adc1ba7cd4686c80700befc6f6575c40b
  1. .github/
  2. .mvn/
  3. log4j-1.2-api/
  4. log4j-api/
  5. log4j-api-java9/
  6. log4j-appserver/
  7. log4j-bom/
  8. log4j-cassandra/
  9. log4j-core/
  10. log4j-core-its/
  11. log4j-core-java9/
  12. log4j-couchdb/
  13. log4j-csv/
  14. log4j-distribution/
  15. log4j-docker/
  16. log4j-flume-ng/
  17. log4j-iostreams/
  18. log4j-jcl/
  19. log4j-jdbc/
  20. log4j-jdbc-dbcp2/
  21. log4j-jeromq/
  22. log4j-jms/
  23. log4j-jmx-gui/
  24. log4j-jpa/
  25. log4j-jpl/
  26. log4j-jul/
  27. log4j-kafka/
  28. log4j-kubernetes/
  29. log4j-layout-jackson/
  30. log4j-layout-jackson-json/
  31. log4j-layout-jackson-xml/
  32. log4j-layout-jackson-yaml/
  33. log4j-layout-template-json/
  34. log4j-liquibase/
  35. log4j-mongodb3/
  36. log4j-mongodb4/
  37. log4j-osgi/
  38. log4j-perf/
  39. log4j-plugins/
  40. log4j-plugins-java9/
  41. log4j-redis/
  42. log4j-samples/
  43. log4j-slf4j-impl/
  44. log4j-slf4j18-impl/
  45. log4j-smtp/
  46. log4j-spring-boot/
  47. log4j-spring-cloud-config/
  48. log4j-taglib/
  49. log4j-to-slf4j/
  50. log4j-web/
  51. src/
  52. .asf.yaml
  53. .dockerignore
  54. .gitattributes
  55. .gitignore
  56. BUILDING.md
  57. checkstyle-header.txt
  58. checkstyle-import-control.xml
  59. checkstyle-suppressions.xml
  60. checkstyle.xml
  61. CONTRIBUTING.md
  62. Dockerfile
  63. LICENSE.txt
  64. mvnw
  65. mvnw.cmd
  66. NOTICE.txt
  67. pom.xml
  68. README.md
  69. RELEASE-NOTES.md
  70. SECURITY.md
  71. spotbugs-exclude-filter.xml
  72. toolchains-docker.xml
  73. toolchains-sample-linux.xml
  74. toolchains-sample-mac.xml
  75. 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 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 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.