activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Timothy Bish (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (AMQ-2845) log4j conf reload via jmx ignores log4j.configuration setting
Date Thu, 11 Aug 2011 19:16:27 GMT

     [ https://issues.apache.org/jira/browse/AMQ-2845?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Timothy Bish resolved AMQ-2845.
-------------------------------

       Resolution: Fixed
    Fix Version/s: 5.6.0

Patch applied, thanks.

> log4j conf reload via jmx ignores log4j.configuration setting
> -------------------------------------------------------------
>
>                 Key: AMQ-2845
>                 URL: https://issues.apache.org/jira/browse/AMQ-2845
>             Project: ActiveMQ
>          Issue Type: Improvement
>          Components: Broker
>    Affects Versions: 5.3.2
>         Environment: N/A
>            Reporter: ZP Gu
>            Priority: Minor
>             Fix For: 5.6.0
>
>         Attachments: BrokerView.java.patch
>
>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message