activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ZP Gu (JIRA)" <j...@apache.org>
Subject [jira] Created: (AMQ-2845) log4j conf reload via jmx ignores log4j.configuration setting
Date Wed, 21 Jul 2010 16:04:51 GMT
log4j conf reload via jmx ignores log4j.configuration setting
-------------------------------------------------------------

                 Key: AMQ-2845
                 URL: https://issues.apache.org/activemq/browse/AMQ-2845
             Project: ActiveMQ
          Issue Type: Improvement
          Components: Broker
    Affects Versions: 5.3.2
         Environment: N/A
            Reporter: ZP Gu
            Priority: Minor


If you start your AMQ with log4j.configuration setting (via -D command line, for example),
and then reload log4j via mbean with BrokerView.java::reloadLog4jProperties(), the log4j.configuration
is ignored, and it went straight to searching for log4j.properties.

Here's diff for the fix:

--- BrokerView.java.ORIG        2010-04-26 17:57:20.000000000 -0400
+++ BrokerView.java     2010-07-20 09:14:31.000000000 -0400
@@ -23,6 +23,7 @@
 import java.net.URI;
 import java.net.URL;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.net.MalformedURLException;
 
 import javax.management.ObjectName;
 
@@ -321,8 +322,19 @@
             
             Method resetConfiguration = logManagerClass.getMethod("resetConfiguration", new
Class[]{});
             resetConfiguration.invoke(null, new Object[]{});
-            
-            URL log4jprops = cl.getResource("log4j.properties");
+
+           String configurationOptionStr = System.getProperty("log4j.configuration");
+           URL log4jprops = null;
+           if (configurationOptionStr != null) {
+               try {
+                   log4jprops = new URL(configurationOptionStr);
+               } catch (MalformedURLException ex) {
+                   log4jprops = cl.getResource("log4j.properties");
+               }
+           } else {
+              log4jprops = cl.getResource("log4j.properties");
+           }
+
             if (log4jprops != null) {
                 Class propertyConfiguratorClass = cl.loadClass("org.apache.log4j.PropertyConfigurator");
                 Method configure = propertyConfiguratorClass.getMethod("configure", new Class[]{URL.class});


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message