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/05 23:21:43 UTC

[logging-log4j2] branch release-2.x updated (31348a9 -> 5be6755)

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 31348a9  Log4j 1.2 bridge adds org.apache.log4j.spi.RootLogger.
     new bc0abcd  Log4j 1.2 bridge class Category is missing some protected instance variables.
     new 5be6755  Log4j 1.2 bridge class Category is missing some protected instance variables.

The 2 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:
 .../src/main/java/org/apache/log4j/Category.java   | 60 ++++++++++++++++++----
 src/changes/changes.xml                            |  3 ++
 2 files changed, 54 insertions(+), 9 deletions(-)

[logging-log4j2] 02/02: Log4j 1.2 bridge class Category is missing some protected instance variables.

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 5be67554f3a8d15c5dd86a83edc7793fd6f2b22f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jan 5 18:21:39 2022 -0500

    Log4j 1.2 bridge class Category is missing some protected instance
    variables.
---
 src/changes/changes.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 0f1a6a8..4d17079 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -94,6 +94,9 @@
       <action dev="ggregory" type="fix">
         Log4j 1.2 bridge adds org.apache.log4j.spi.RootLogger.
       </action>
+      <action dev="ggregory" type="fix">
+        Log4j 1.2 bridge class Category is missing some protected instance variables.
+      </action>
       <!-- ADD -->
       <!-- UPDATES -->
 	</release>

[logging-log4j2] 01/02: Log4j 1.2 bridge class Category is missing some protected instance variables.

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 bc0abcdef7c6a2a990cc5f0a896954c2f84b942b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jan 5 18:21:29 2022 -0500

    Log4j 1.2 bridge class Category is missing some protected instance
    variables.
---
 .../src/main/java/org/apache/log4j/Category.java   | 60 ++++++++++++++++++----
 1 file changed, 51 insertions(+), 9 deletions(-)

diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java b/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
index be25086..74e62d2 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
@@ -55,9 +55,7 @@ public class Category implements AppenderAttachable {
     private static final String FQCN = Category.class.getName();
 
     private static final boolean isCoreAvailable;
-
-    private final RendererMap rendererMap;
-
+    
     static {
         boolean available;
 
@@ -70,9 +68,35 @@ public class Category implements AppenderAttachable {
     }
 
     /**
+     * The name of this category.
+     */
+    protected String name;
+
+    /**
+     * Additivity is set to true by default, that is children inherit the appenders of their ancestors by default. If this
+     * variable is set to <code>false</code> then the appenders found in the ancestors of this category are not used.
+     * However, the children of this category will inherit its appenders, unless the children have their additivity flag set
+     * to <code>false</code> too. See the user manual for more details.
+     */
+    protected boolean additive = true;
+    
+    /**
+     * The assigned level of this category. The <code>level</code> variable need not be assigned a value in which case it is
+     * inherited form the hierarchy.
+     */
+    volatile protected Level level;
+
+    private final RendererMap rendererMap;
+
+    /**
+     * The parent of this category. All categories have at least one ancestor which is the root category.
+     */
+    volatile protected Category parent;
+
+    /**
      * Resource bundle for localized messages.
      */
-    protected ResourceBundle bundle = null;
+    protected ResourceBundle bundle;
 
     private final org.apache.logging.log4j.Logger logger;
 
@@ -85,9 +109,10 @@ public class Category implements AppenderAttachable {
      * @param name The name of the Logger.
      */
     protected Category(final LoggerContext context, final String name) {
-        logger = context.getLogger(name);
-        repository = LogManager.getLoggerRepository();
-        rendererMap = ((RendererSupport) repository).getRendererMap();
+        this.name = name;
+        this.logger = context.getLogger(name);
+        this.repository = LogManager.getLoggerRepository();
+        this.rendererMap = ((RendererSupport) repository).getRendererMap();
     }
 
     /**
@@ -159,8 +184,8 @@ public class Category implements AppenderAttachable {
             return null;
         }
         final ConcurrentMap<String, Logger> loggers = getLoggersMap(loggerContext);
-        final Logger l = loggers.get(parent.getName());
-        return l == null ? new Category(parent) : l;
+        final Logger parentLogger = loggers.get(parent.getName());
+        return parentLogger == null ? new Category(parent) : parentLogger;
     }
 
     public static Category getRoot() {
@@ -377,6 +402,23 @@ public class Category implements AppenderAttachable {
     public void callAppenders(final LoggingEvent event) {
     }
 
+    /**
+     * Closes all attached appenders implementing the AppenderAttachable interface.
+     *
+     * @since 1.0
+     */
+    synchronized void closeNestedAppenders() {
+        Enumeration enumeration = this.getAllAppenders();
+        if (enumeration != null) {
+            while (enumeration.hasMoreElements()) {
+                Appender a = (Appender) enumeration.nextElement();
+                if (a instanceof AppenderAttachable) {
+                    a.close();
+                }
+            }
+        }
+    }
+
     @Override
     @SuppressWarnings("rawtypes")
     public Enumeration getAllAppenders() {