This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 44d06948e29c365ac3920e6865832fc1dfd20297 Author: Gary Gregory <[email protected]> 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 8438243..1d3a442 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() { @@ -374,6 +399,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() {
