logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r673909 - /logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java
Date Fri, 04 Jul 2008 05:26:15 GMT
Author: sdeboy
Date: Thu Jul  3 22:26:14 2008
New Revision: 673909

URL: http://svn.apache.org/viewvc?rev=673909&view=rev
Log:
When configuration URL changes, trigger a load of the configuration.

This doesn't clear the receivers tree, it just triggers a call to DOMConfigurator.configure.

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java?rev=673909&r1=673908&r2=673909&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java Thu Jul  3 22:26:14
2008
@@ -311,7 +311,7 @@
 			});
     }
     
-    LogUI logUI = new LogUI();
+    final LogUI logUI = new LogUI();
     logUI.applicationPreferenceModel = model;
 
     if (model.isShowSplash()) {
@@ -367,9 +367,26 @@
           URL configURL = new URL(config);
           logUI.loadConfigurationUsingPluginClassLoader(configURL);
         }catch(MalformedURLException e) {
-            logger.error("Failed to convert config string to url", e);
+            logger.error("Initial configuration - failed to convert config string to url",
e);
         }
     }
+    
+    //register a listener to load the configuration when it changes (avoid having to restart
Chainsaw when applying a new configuration)
+    //this doesn't remove receivers from receivers panel, it just triggers DOMConfigurator.configure.
+	model.addPropertyChangeListener("configurationURL", new PropertyChangeListener() {
+        public void propertyChange(PropertyChangeEvent evt) {
+            String newConfiguration = evt.getNewValue().toString();
+            if (newConfiguration != null && !(newConfiguration.trim().equals("")))
{
+                newConfiguration = newConfiguration.trim();
+                try {
+                    logger.info("loading updated configuration: " + newConfiguration);
+                    URL newConfigurationURL = new URL(newConfiguration);
+                    logUI.loadConfigurationUsingPluginClassLoader(newConfigurationURL);
+                } catch (MalformedURLException e) {
+                    logger.error("Updated configuration - failed to convert config string
to URL", e);
+                }
+            }
+        }});
 
     if (config == null) {
       logger.info("No auto-configuration file found within the ApplicationPreferenceModel");



Mime
View raw message