You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ck...@apache.org on 2021/06/04 16:57:19 UTC
[logging-log4j2] branch release-2.x updated: Fix incorrect
LogManager accessor used by LOG4J2-2940
This is an automated email from the ASF dual-hosted git repository.
ckozak pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/release-2.x by this push:
new 86ce2e3 Fix incorrect LogManager accessor used by LOG4J2-2940
86ce2e3 is described below
commit 86ce2e3dcff991a5a275383c282292ce0fb1cef6
Author: Carter Kozak <ck...@apache.org>
AuthorDate: Fri Jun 4 09:23:43 2021 -0400
Fix incorrect LogManager accessor used by LOG4J2-2940
The `getContext()` accessor with no args has been used as a fallback
for Log4jLoggerFactory slf4j implementations for a while, but it's
much more likely to be used now that LOG4J2-2940 is resolved.
Without the `false` argument, the first slf4j LoggerFactory.getLogger
call will not cause log4j to initialize itself.
---
.../src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java | 2 +-
.../src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
index f513f0d..578d182 100644
--- a/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
+++ b/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
@@ -45,7 +45,7 @@ public class Log4jLoggerFactory extends AbstractLoggerAdapter<Logger> implements
? StackLocatorUtil.getCallerClass(FQCN, PACKAGE, 1)
: null;
return anchor == null
- ? LogManager.getContext()
+ ? LogManager.getContext(false)
: getContext(anchor);
}
private LoggerContext validateContext(final LoggerContext context) {
diff --git a/log4j-slf4j18-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java b/log4j-slf4j18-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
index 3404e0b..be29dad 100644
--- a/log4j-slf4j18-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
+++ b/log4j-slf4j18-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
@@ -51,7 +51,7 @@ public class Log4jLoggerFactory extends AbstractLoggerAdapter<Logger> implements
? StackLocatorUtil.getCallerClass(FQCN, PACKAGE, 1)
: null;
return anchor == null
- ? LogManager.getContext()
+ ? LogManager.getContext(false)
: getContext(anchor);
}