Author: jake
Date: Wed Aug 31 18:28:39 2011
New Revision: 1163736
URL: http://svn.apache.org/viewvc?rev=1163736&view=rev
Log:
Optionally skip log4j configuration
Patch by tjake; reviewed by Aaron Morton for CASSANDRA-3061
Modified:
cassandra/branches/cassandra-0.8/CHANGES.txt
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
Modified: cassandra/branches/cassandra-0.8/CHANGES.txt
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/CHANGES.txt?rev=1163736&r1=1163735&r2=1163736&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.8/CHANGES.txt Wed Aug 31 18:28:39 2011
@@ -49,7 +49,7 @@
* make repair report failure when a node participating dies (instead of
hanging forever) (CASSANDRA-2433)
* fix handling of the empty byte buffer by ReversedType (CASSANDRA-3111)
-
+ * optionally skip log4j configuration (CASSANDRA-3061)
0.8.4
* include files-to-be-streamed in StreamInSession.getSources (CASSANDRA-2972)
Modified:
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java?rev=1163736&r1=1163735&r2=1163736&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
(original)
+++
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
Wed Aug 31 18:28:39 2011
@@ -67,40 +67,43 @@ public abstract class AbstractCassandraD
*/
public static void initLog4j()
{
- String config = System.getProperty("log4j.configuration",
"log4j-server.properties");
- URL configLocation = null;
- try
- {
- // try loading from a physical location first.
- configLocation = new URL(config);
- }
- catch (MalformedURLException ex)
+ if
(System.getProperty("log4j.defaultInitOverride","false").equalsIgnoreCase("true"))
{
- // then try loading from the classpath.
- configLocation =
AbstractCassandraDaemon.class.getClassLoader().getResource(config);
- }
+ String config = System.getProperty("log4j.configuration",
"log4j-server.properties");
+ URL configLocation = null;
+ try
+ {
+ // try loading from a physical location first.
+ configLocation = new URL(config);
+ }
+ catch (MalformedURLException ex)
+ {
+ // then try loading from the classpath.
+ configLocation =
AbstractCassandraDaemon.class.getClassLoader().getResource(config);
+ }
- if (configLocation == null)
- throw new RuntimeException("Couldn't figure out log4j
configuration: "+config);
+ if (configLocation == null)
+ throw new RuntimeException("Couldn't figure out log4j
configuration: "+config);
- // Now convert URL to a filename
- String configFileName = null;
- try
- {
- // first try URL.getFile() which works for opaque URLs (file:foo)
and paths without spaces
- configFileName = configLocation.getFile();
- File configFile = new File(configFileName);
- // then try alternative approach which works for all hierarchical
URLs with or without spaces
- if (!configFile.exists())
- configFileName = new
File(configLocation.toURI()).getCanonicalPath();
- }
- catch (Exception e)
- {
- throw new RuntimeException("Couldn't convert log4j configuration
location to a valid file", e);
- }
+ // Now convert URL to a filename
+ String configFileName = null;
+ try
+ {
+ // first try URL.getFile() which works for opaque URLs
(file:foo) and paths without spaces
+ configFileName = configLocation.getFile();
+ File configFile = new File(configFileName);
+ // then try alternative approach which works for all
hierarchical URLs with or without spaces
+ if (!configFile.exists())
+ configFileName = new
File(configLocation.toURI()).getCanonicalPath();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Couldn't convert log4j
configuration location to a valid file", e);
+ }
- PropertyConfigurator.configureAndWatch(configFileName, 10000);
-
org.apache.log4j.Logger.getLogger(AbstractCassandraDaemon.class).info("Logging
initialized");
+ PropertyConfigurator.configureAndWatch(configFileName, 10000);
+
org.apache.log4j.Logger.getLogger(AbstractCassandraDaemon.class).info("Logging
initialized");
+ }
}
private static Logger logger =
LoggerFactory.getLogger(AbstractCassandraDaemon.class);