log4j configuration wasn't handling configurations specified by URL. patch by Gary Dusbabek, reviewed by Jake Luciani. CASSANDRA-1907

git-svn-id: https://svn.apache.org/repos/asf/cassandra/branches/cassandra-0.7@1053205 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Dusbabek 2010-12-27 22:13:53 +00:00
parent 6f8537bb19
commit 88f47b80c5
2 changed files with 17 additions and 1 deletions

View File

@ -9,6 +9,7 @@ dev
* avoid polluting page cache with commitlog or sstable writes
and seq scan operations (CASSANDRA-1470)
* add OpenBitSet to support larger bloom filters (CASSANDRA-1555)
* handle URL-specified log4j regression (CASSANDRA-1907)
0.7.0-rc3

View File

@ -21,6 +21,8 @@ package org.apache.cassandra.service;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.UUID;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.SynchronousQueue;
@ -59,7 +61,20 @@ public abstract class AbstractCassandraDaemon implements CassandraDaemon
static
{
String config = System.getProperty("log4j.configuration", "log4j-server.properties");
PropertyConfigurator.configureAndWatch(ClassLoader.getSystemResource(config).getFile(), 10000);
URL configLocation = null;
try
{
// try loading from a physical location first.
configLocation = new URL(config);
}
catch (MalformedURLException ex)
{
// load from the classpath.
configLocation = AbstractCassandraDaemon.class.getClassLoader().getResource(config);
if (configLocation == null)
throw new RuntimeException("Couldn't figure out log4j configuration.");
}
PropertyConfigurator.configureAndWatch(configLocation.getFile(), 10000);
org.apache.log4j.Logger.getLogger(AbstractCassandraDaemon.class).info("Logging initialized");
}