git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1156748 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2011-08-11 19:14:50 +00:00
parent 7a46a1c368
commit b4b39509a9
1 changed files with 15 additions and 3 deletions

View File

@ -20,6 +20,7 @@ import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.concurrent.atomic.AtomicInteger;
@ -321,14 +322,25 @@ public class BrokerView implements BrokerViewMBean {
// Avoid a direct dependency on log4j.. use reflection.
try {
ClassLoader cl = getClass().getClassLoader();
Class logManagerClass = cl.loadClass("org.apache.log4j.LogManager");
Class<?> logManagerClass = cl.loadClass("org.apache.log4j.LogManager");
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");
Class<?> propertyConfiguratorClass = cl.loadClass("org.apache.log4j.PropertyConfigurator");
Method configure = propertyConfiguratorClass.getMethod("configure", new Class[]{URL.class});
configure.invoke(null, new Object[]{log4jprops});
}