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 2018/10/13 17:31:28 UTC
logging-log4j2 git commit: Add timing information to DEBUG logging on
reconfiguration;
handy to capture how changes to a JDBC Appender for example affects
reconfiguration as acquiring database connection can be slow sometimes.
Repository: logging-log4j2
Updated Branches:
refs/heads/release-2.x 60dadf37c -> 01b69e39e
Add timing information to DEBUG logging on reconfiguration; handy to
capture how changes to a JDBC Appender for example affects
reconfiguration as acquiring database connection can be slow sometimes.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/01b69e39
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/01b69e39
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/01b69e39
Branch: refs/heads/release-2.x
Commit: 01b69e39ea5daf5a5e4033ebc96eb1d0f06cfc73
Parents: 60dadf3
Author: Gary Gregory <gg...@rocketsoftware.com>
Authored: Sat Oct 13 11:31:24 2018 -0600
Committer: Gary Gregory <gg...@rocketsoftware.com>
Committed: Sat Oct 13 11:31:24 2018 -0600
----------------------------------------------------------------------
.../logging/log4j/core/LoggerContext.java | 25 +++++++++++---------
1 file changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/01b69e39/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
index 8234024..a29eda8 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
@@ -662,17 +662,20 @@ public class LoggerContext extends AbstractLifeCycle
* @param reconfigurable The Configuration that can be reconfigured.
*/
@Override
- public synchronized void onChange(final Reconfigurable reconfigurable) {
- LOGGER.debug("Reconfiguration started for context {} ({})", contextName, this);
- initApiModule();
- final Configuration newConfig = reconfigurable.reconfigure();
- if (newConfig != null) {
- setConfiguration(newConfig);
- LOGGER.debug("Reconfiguration completed for {} ({})", contextName, this);
- } else {
- LOGGER.debug("Reconfiguration failed for {} ({})", contextName, this);
- }
- }
+ public synchronized void onChange(final Reconfigurable reconfigurable) {
+ final long startMillis = System.currentTimeMillis();
+ LOGGER.debug("Reconfiguration started for context {} ({})", contextName, this);
+ initApiModule();
+ final Configuration newConfig = reconfigurable.reconfigure();
+ if (newConfig != null) {
+ setConfiguration(newConfig);
+ LOGGER.debug("Reconfiguration completed for {} ({}) in {} milliseconds.", contextName, this,
+ System.currentTimeMillis() - startMillis);
+ } else {
+ LOGGER.debug("Reconfiguration failed for {} ({}) in {} milliseconds.", contextName, this,
+ System.currentTimeMillis() - startMillis);
+ }
+ }
private void initApiModule() {
ThreadContextMapFactory.init(); // Or make public and call ThreadContext.init() which calls ThreadContextMapFactory.init().