You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2020/09/12 17:33:12 UTC
[logging-log4j2] 01/03: LOG4J2-2919 Call ReliabilityStrategy's
beforeStopAppenders() method before stopping AsyncAppenders to avoid errors
caused by logging with AsyncAppender while system is reconfiguring
Submitted by: gengyuanzhe
This is an automated email from the ASF dual-hosted git repository.
mattsicker pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 1aabc2e3048784f5fb28a55167c93332f3bb2e8e
Author: gengyuanzhe <ge...@gmail.com>
AuthorDate: Tue Sep 8 01:02:14 2020 +0800
LOG4J2-2919
Call ReliabilityStrategy's beforeStopAppenders() method before stopping AsyncAppenders
to avoid errors caused by logging with AsyncAppender while system is reconfiguring
Submitted by: gengyuanzhe <ge...@gmail.com>
---
.../logging/log4j/core/config/AbstractConfiguration.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
index 42e9940..9cae60d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
@@ -369,6 +369,12 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
asyncLoggerConfigDisruptor.stop(timeout, timeUnit);
}
+ LOGGER.trace("{} notifying ReliabilityStrategies that appenders will be stopped.", cls);
+ for (final LoggerConfig loggerConfig : loggerConfigs.values()) {
+ loggerConfig.getReliabilityStrategy().beforeStopAppenders();
+ }
+ root.getReliabilityStrategy().beforeStopAppenders();
+
// Stop the appenders in reverse order in case they still have activity.
final Appender[] array = appenders.values().toArray(new Appender[appenders.size()]);
final List<Appender> async = getAsyncAppenders(array);
@@ -384,12 +390,6 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
}
}
- LOGGER.trace("{} notifying ReliabilityStrategies that appenders will be stopped.", cls);
- for (final LoggerConfig loggerConfig : loggerConfigs.values()) {
- loggerConfig.getReliabilityStrategy().beforeStopAppenders();
- }
- root.getReliabilityStrategy().beforeStopAppenders();
-
LOGGER.trace("{} stopping remaining Appenders.", cls);
int appenderCount = 0;
for (int i = array.length - 1; i >= 0; --i) {