You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2015/09/20 10:25:21 UTC
[03/12] logging-log4j2 git commit: LOG4J2-1121 AbstractConfiguration
notifies the ReliabilityStrategy of each LoggerConfig that the config is
stopping and that the appenders will be stopped
LOG4J2-1121 AbstractConfiguration notifies the ReliabilityStrategy of
each LoggerConfig that the config is stopping and that the appenders
will be stopped
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/86dde4ee
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/86dde4ee
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/86dde4ee
Branch: refs/heads/master
Commit: 86dde4ee7e29968621029b554eeaecbc270ae2f2
Parents: c817d70
Author: rpopma <rp...@apache.org>
Authored: Sun Sep 20 05:32:39 2015 +0900
Committer: rpopma <rp...@apache.org>
Committed: Sun Sep 20 05:32:39 2015 +0900
----------------------------------------------------------------------
.../core/config/AbstractConfiguration.java | 26 ++++++++++++++------
1 file changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/86dde4ee/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
----------------------------------------------------------------------
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 8d1cb41..152e667 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
@@ -196,6 +196,12 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
public void stop() {
this.setStopping();
LOGGER.trace("Stopping {}...", this);
+
+ for (final LoggerConfig loggerConfig : loggers.values()) {
+ loggerConfig.getReliabilityStrategy().beforeStopConfiguration(this);
+ }
+ LOGGER.trace("AbstractConfiguration notified {} ReliabilityStrategies that config will be stopped.",
+ loggers.size());
// LOG4J2-392 first stop AsyncLogger Disruptor thread
final LoggerContextFactory factory = LogManager.getFactory();
@@ -246,6 +252,12 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
}
LOGGER.trace("AbstractConfiguration stopped {} AsyncAppenders.", asyncAppenderCount);
+ for (final LoggerConfig loggerConfig : loggers.values()) {
+ loggerConfig.getReliabilityStrategy().beforeStopAppenders();
+ }
+ LOGGER.trace("AbstractConfiguration notified {} ReliabilityStrategies that appenders will be stopped.",
+ loggers.size());
+
int appenderCount = 0;
for (int i = array.length - 1; i >= 0; --i) {
if (array[i].isStarted()) { // then stop remaining Appenders
@@ -256,20 +268,18 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
LOGGER.trace("AbstractConfiguration stopped {} Appenders.", appenderCount);
int loggerCount = 0;
- for (final LoggerConfig logger : loggers.values()) {
- // clear appenders, even if this logger is already stopped.
- logger.clearAppenders();
+ for (final LoggerConfig loggerConfig : loggers.values()) {
// AsyncLoggerConfigHelper decreases its ref count when an AsyncLoggerConfig is stopped.
// Stopping the same AsyncLoggerConfig twice results in an incorrect ref count and
// the shared Disruptor may be shut down prematurely, resulting in NPE or other errors.
- if (alreadyStopped.contains(logger)) {
- continue;
+ if (!alreadyStopped.contains(loggerConfig)) {
+ loggerConfig.stop();
+ loggerCount++;
}
- logger.stop();
- loggerCount++;
+ loggerConfig.clearAppenders();
}
- LOGGER.trace("AbstractConfiguration stopped {} Loggers.", loggerCount);
+ LOGGER.trace("AbstractConfiguration stopped {} LoggerConfigs.", loggerCount);
// AsyncLoggerConfigHelper decreases its ref count when an AsyncLoggerConfig is stopped.
// Stopping the same AsyncLoggerConfig twice results in an incorrect ref count and