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 2015/03/01 23:40:36 UTC
logging-log4j2 git commit: [LOG4J2-947] A new StatusLoggerAdmin
listener is added to StatusLogger every time the log is reconfigured.
Repository: logging-log4j2
Updated Branches:
refs/heads/master 2f14d3f03 -> a87c1e37b
[LOG4J2-947] A new StatusLoggerAdmin listener is added to StatusLogger
every time the log is reconfigured.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/a87c1e37
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/a87c1e37
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/a87c1e37
Branch: refs/heads/master
Commit: a87c1e37b003f85ffe7f64df3c86120b0ace767f
Parents: 2f14d3f
Author: Gary Gregory <ga...@gmail.com>
Authored: Sun Mar 1 14:40:34 2015 -0800
Committer: Gary Gregory <ga...@gmail.com>
Committed: Sun Mar 1 14:40:34 2015 -0800
----------------------------------------------------------------------
.../log4j/core/jmx/StatusLoggerAdmin.java | 20 ++++++++++++++++++++
src/changes/changes.xml | 3 +++
2 files changed, 23 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a87c1e37/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/StatusLoggerAdmin.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/StatusLoggerAdmin.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/StatusLoggerAdmin.java
index 980944e..b2377dc 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/StatusLoggerAdmin.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/StatusLoggerAdmin.java
@@ -63,9 +63,29 @@ public class StatusLoggerAdmin extends NotificationBroadcasterSupport implements
} catch (final Exception e) {
throw new IllegalStateException(e);
}
+ removeListeners(contextName);
StatusLogger.getLogger().registerListener(this);
}
+ /**
+ * Add listener to StatusLogger for this context, or replace it if it already exists.
+ *
+ * @param ctxName
+ */
+ private void removeListeners(final String ctxName) {
+ final StatusLogger logger = StatusLogger.getLogger();
+ final Iterable<StatusListener> listeners = logger.getListeners();
+ // Remove any StatusLoggerAdmin listeners already registered for this context
+ for (final StatusListener statusListener : listeners) {
+ if (statusListener instanceof StatusLoggerAdmin) {
+ final StatusLoggerAdmin adminListener = (StatusLoggerAdmin) statusListener;
+ if (ctxName != null && ctxName.equals(adminListener.contextName)) {
+ logger.removeListener(adminListener);
+ }
+ }
+ }
+ }
+
private static MBeanNotificationInfo createNotificationInfo() {
final String[] notifTypes = new String[] {//
NOTIF_TYPE_DATA, NOTIF_TYPE_MESSAGE };
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a87c1e37/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 349d9e6..e3b1833 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -27,6 +27,9 @@
<action issue="LOG4J2-964" dev="ggregory" type="fix" due-to="Jonne JyrylÀ">
StringFormattedMessage serialization is incorrect.
</action>
+ <action issue="LOG4J2-947" dev="ggregory" type="fix" due-to=" Stefan Wehner">
+ A new StatusLoggerAdmin listener is added to StatusLogger every time the log is reconfigured.
+ </action>
</release>
<release version="2.2" date="2015-02-22" description="GA Release 2.2">
<action issue="LOG4J2-938" dev="rpopma" type="fix" due-to="Mauro Molinari">