You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2022/01/12 13:09:12 UTC

[logging-log4j2] branch release-2.x updated (7cdb199 -> 8a77923)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git.


    from 7cdb199  Use final and simpler hashcode generation through Objects.
     new 86bde5d  Bump maven-shade-plugin.log4j2-cachefile-transformer 2.14.1 to 2.15.0.
     new 585df00  [LOG4J2-3330] Configurator.setLevel not fetching the correct LoggerContext.
     new 8a77923  [LOG4J2-3330] Configurator.setLevel not fetching the correct LoggerContext.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/logging/log4j/core/config/Configurator.java    | 15 ++++++++++-----
 log4j-perf/pom.xml                                        |  2 +-
 src/changes/changes.xml                                   |  3 +++
 3 files changed, 14 insertions(+), 6 deletions(-)

[logging-log4j2] 02/03: [LOG4J2-3330] Configurator.setLevel not fetching the correct LoggerContext.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 585df0052ccf7a9d0ff2bc2a625c975ff9eceb09
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jan 12 08:09:04 2022 -0500

    [LOG4J2-3330] Configurator.setLevel not fetching the correct
    LoggerContext.
---
 .../apache/logging/log4j/core/config/Configurator.java    | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java
index 6ed1420..de69bcf 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java
@@ -24,6 +24,7 @@ import org.apache.logging.log4j.core.impl.Log4jContextFactory;
 import org.apache.logging.log4j.core.util.NetUtils;
 import org.apache.logging.log4j.spi.LoggerContextFactory;
 import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.util.StackLocatorUtil;
 import org.apache.logging.log4j.util.Strings;
 
 import java.net.URI;
@@ -303,6 +304,7 @@ public final class Configurator {
 
     /**
      * Sets the levels of <code>parentLogger</code> and all 'child' loggers to the given <code>level</code>.
+     *
      * @param parentLogger the parent logger
      * @param level the new level
      */
@@ -312,7 +314,7 @@ public final class Configurator {
         // 3) set level on logger config
         // 4) update child logger configs with level
         // 5) update loggers
-        final LoggerContext loggerContext = LoggerContext.getContext(false);
+        final LoggerContext loggerContext = LoggerContext.getContext(StackLocatorUtil.getCallerClassLoader(2), false, null);
         final Configuration config = loggerContext.getConfiguration();
         boolean set = setLevel(parentLogger, level, config);
         for (final Map.Entry<String, LoggerConfig> entry : config.getLoggers().entrySet()) {
@@ -341,7 +343,7 @@ public final class Configurator {
      *            Levels.
      */
     public static void setLevel(final Map<String, Level> levelMap) {
-        final LoggerContext loggerContext = LoggerContext.getContext(false);
+        final LoggerContext loggerContext = LoggerContext.getContext(StackLocatorUtil.getCallerClassLoader(2), false, null);
         final Configuration config = loggerContext.getConfiguration();
         boolean set = false;
         for (final Map.Entry<String, Level> entry : levelMap.entrySet()) {
@@ -363,9 +365,9 @@ public final class Configurator {
      *            the new level
      */
     public static void setLevel(final String loggerName, final Level level) {
-        final LoggerContext loggerContext = LoggerContext.getContext(false);
+        final LoggerContext loggerContext = LoggerContext.getContext(StackLocatorUtil.getCallerClassLoader(2), false, null);
         if (Strings.isEmpty(loggerName)) {
-            setRootLevel(level);
+            setRootLevel(level, loggerContext);
         } else if (setLevel(loggerName, level, loggerContext.getConfiguration())) {
             loggerContext.updateLoggers();
         }
@@ -393,7 +395,10 @@ public final class Configurator {
      *            the new level
      */
     public static void setRootLevel(final Level level) {
-        final LoggerContext loggerContext = LoggerContext.getContext(false);
+        setRootLevel(level, LoggerContext.getContext(StackLocatorUtil.getCallerClassLoader(2), false, null));
+    }
+
+    private static void setRootLevel(final Level level, final LoggerContext loggerContext) {
         final LoggerConfig loggerConfig = loggerContext.getConfiguration().getRootLogger();
         if (!loggerConfig.getLevel().equals(level)) {
             loggerConfig.setLevel(level);

[logging-log4j2] 03/03: [LOG4J2-3330] Configurator.setLevel not fetching the correct LoggerContext.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 8a77923fb8f451dc1f3e52c6e64e154c8bc2bcba
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jan 12 08:09:09 2022 -0500

    [LOG4J2-3330] Configurator.setLevel not fetching the correct
    LoggerContext.
---
 src/changes/changes.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index dcc2d67..ee1978c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -127,6 +127,9 @@
       <action dev="ggregory" type="fix">
         JndiManager reverts to 2.17.0 behavior: Read the system property for each call.
       </action>
+      <action dev="ggregory" type="fix" issue="LOG4J2-3330" due-to="Mircea Lemnaru, Gary Gregory">
+        Configurator.setLevel not fetching the correct LoggerContext.
+      </action>
       <!-- ADD -->
       <action issue="LOG4J2-3282" dev="ckozak" type="add" due-to="Michael Vorburger">
         Add the log4j-to-jul JDK Logging Bridge

[logging-log4j2] 01/03: Bump maven-shade-plugin.log4j2-cachefile-transformer 2.14.1 to 2.15.0.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 86bde5ddb0eda886294f7f2ec972e835b8e5c99b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jan 12 08:07:12 2022 -0500

    Bump maven-shade-plugin.log4j2-cachefile-transformer 2.14.1 to 2.15.0.
---
 log4j-perf/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/log4j-perf/pom.xml b/log4j-perf/pom.xml
index 985e328..4ada089 100644
--- a/log4j-perf/pom.xml
+++ b/log4j-perf/pom.xml
@@ -235,7 +235,7 @@
           <dependency>
             <groupId>com.github.edwgiz</groupId>
             <artifactId>maven-shade-plugin.log4j2-cachefile-transformer</artifactId>
-            <version>2.14.1</version>
+            <version>2.15.0</version>
           </dependency>
         </dependencies>
       </plugin>