From dff06e7f130261d09e72137f67776a74da48347d Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Tue, 16 Jan 2024 10:28:24 +0100 Subject: [PATCH 1/2] Restore compatibility of Log4j API This restores backward compatibility of `log4j-api` from a user's perspective and adds comments to classes that should not have breaking changes. I have checked all the types in `org.apache.logging.log4j` and those reachable through inheritance or signature of public methods in other packages: ``` org.apache.logging.log4j.message.EntryMessage org.apache.logging.log4j.message.ExitMessage org.apache.logging.log4j.message.FlowMessage org.apache.logging.log4j.message.FlowMessageFactory org.apache.logging.log4j.message.Message org.apache.logging.log4j.message.MessageFactory org.apache.logging.log4j.spi.LoggerContext org.apache.logging.log4j.spi.ExtendedLogger org.apache.logging.log4j.spi.LoggerContextFactory org.apache.logging.log4j.spi.LoggerRegistry org.apache.logging.log4j.spi.StandardLevel org.apache.logging.log4j.spi.ReadOnlyThreadContextMap org.apache.logging.log4j.util.BiConsumer org.apache.logging.log4j.util.ReadOnlyStringMap org.apache.logging.log4j.util.StringMap org.apache.logging.log4j.util.StringBuilderFormattable org.apache.logging.log4j.util.Supplier org.apache.logging.log4j.util.TriConsumer ``` The only breaking changes I found are `Logger#entry/exit` and in `MarkerFactory`. I believe we should restore them and have a 100% binary compatibility with `2.x`, rather then breaking BC for almost nothing. --- log4j-api/pom.xml | 1 + .../java/org/apache/logging/log4j/Level.java | 2 + .../org/apache/logging/log4j/LogManager.java | 8 +- .../java/org/apache/logging/log4j/Logger.java | 205 ++++++++++++++---- .../java/org/apache/logging/log4j/Marker.java | 3 + .../apache/logging/log4j/MarkerManager.java | 38 ++++ .../apache/logging/log4j/ThreadContext.java | 2 + .../apache/logging/log4j/package-info.java | 7 +- .../logging/log4j/spi/ExtendedLogger.java | 9 +- .../logging/log4j/spi/LoggerContext.java | 4 + .../log4j/spi/LoggerContextFactory.java | 4 + .../logging/log4j/spi/LoggerRegistry.java | 3 + .../log4j/spi/ReadOnlyThreadContextMap.java | 3 +- .../logging/log4j/spi/StandardLevel.java | 4 + .../apache/logging/log4j/util/BiConsumer.java | 5 +- .../logging/log4j/util/MessageSupplier.java | 8 +- .../logging/log4j/util/ReadOnlyStringMap.java | 7 +- .../log4j/util/StringBuilderFormattable.java | 4 +- .../apache/logging/log4j/util/StringMap.java | 6 +- .../apache/logging/log4j/util/Supplier.java | 2 +- .../logging/log4j/util/TriConsumer.java | 4 +- .../resources/log4j2.propertyMapping.json | 2 + 22 files changed, 270 insertions(+), 61 deletions(-) diff --git a/log4j-api/pom.xml b/log4j-api/pom.xml index 5db39f09bdd..249887921c7 100644 --- a/log4j-api/pom.xml +++ b/log4j-api/pom.xml @@ -29,6 +29,7 @@ The Apache Log4j API false + false