Author: jbellis Date: Wed Dec 22 23:53:40 2010 New Revision: 1052104 URL: http://svn.apache.org/viewvc?rev=1052104&view=rev Log: check log4j configuration for changes every 10s patch by tjake; reviewed by jbellis for CASSANDRA-1525
Modified: cassandra/branches/cassandra-0.7/CHANGES.txt cassandra/branches/cassandra-0.7/bin/cassandra cassandra/branches/cassandra-0.7/bin/cassandra.bat cassandra/branches/cassandra-0.7/conf/log4j-server.properties cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java Modified: cassandra/branches/cassandra-0.7/CHANGES.txt URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1052104&r1=1052103&r2=1052104&view=diff ============================================================================== --- cassandra/branches/cassandra-0.7/CHANGES.txt (original) +++ cassandra/branches/cassandra-0.7/CHANGES.txt Wed Dec 22 23:53:40 2010 @@ -2,6 +2,7 @@ dev * fix cli crash after backgrounding (CASSANDRA-1875) * count timeouts in storageproxy latencies, and include latency histograms in StorageProxyMBean (CASSANDRA-1893) + * check log4j configuration for changes every 10s (CASSANDRA-1525) 0.7.0-rc3 Modified: cassandra/branches/cassandra-0.7/bin/cassandra URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/bin/cassandra?rev=1052104&r1=1052103&r2=1052104&view=diff ============================================================================== --- cassandra/branches/cassandra-0.7/bin/cassandra (original) +++ cassandra/branches/cassandra-0.7/bin/cassandra Wed Dec 22 23:53:40 2010 @@ -108,7 +108,7 @@ launch_service() foreground=$2 props=$3 class=$4 - cassandra_parms="-Dlog4j.configuration=log4j-server.properties" + cassandra_parms="-Dlog4j.configuration=log4j-server.properties -Dlog4j.defaultInitOverride=true" if [ "x$pidpath" != "x" ]; then cassandra_parms="$cassandra_parms -Dcassandra-pidfile=$pidpath" Modified: cassandra/branches/cassandra-0.7/bin/cassandra.bat URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/bin/cassandra.bat?rev=1052104&r1=1052103&r2=1052104&view=diff ============================================================================== --- cassandra/branches/cassandra-0.7/bin/cassandra.bat (original) +++ cassandra/branches/cassandra-0.7/bin/cassandra.bat Wed Dec 22 23:53:40 2010 @@ -37,7 +37,8 @@ set JAVA_OPTS=^ -Dcom.sun.management.jmxremote.port=8080^ -Dcom.sun.management.jmxremote.ssl=false^ -Dcom.sun.management.jmxremote.authenticate=false^ - -Dlog4j.configuration=log4j-server.properties + -Dlog4j.configuration=log4j-server.properties^ + -Dlog4j.defaultInitOverride=true REM ***** CLASSPATH library setting ***** Modified: cassandra/branches/cassandra-0.7/conf/log4j-server.properties URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/conf/log4j-server.properties?rev=1052104&r1=1052103&r2=1052104&view=diff ============================================================================== --- cassandra/branches/cassandra-0.7/conf/log4j-server.properties (original) +++ cassandra/branches/cassandra-0.7/conf/log4j-server.properties Wed Dec 22 23:53:40 2010 @@ -35,6 +35,7 @@ log4j.appender.R.layout.ConversionPatter log4j.appender.R.File=/var/log/cassandra/system.log # Application logging options -#log4j.logger.com.facebook=DEBUG -#log4j.logger.com.facebook.infrastructure.gms=DEBUG -#log4j.logger.com.facebook.infrastructure.db=DEBUG +#log4j.logger.org.apache.cassandra=DEBUG +#log4j.logger.org.apache.cassandra.db=DEBUG +#log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG + Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java?rev=1052104&r1=1052103&r2=1052104&view=diff ============================================================================== --- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java (original) +++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java Wed Dec 22 23:53:40 2010 @@ -42,6 +42,7 @@ import org.apache.cassandra.db.migration import org.apache.cassandra.utils.CLibrary; import org.apache.cassandra.utils.FBUtilities; import org.apache.cassandra.utils.Mx4jTool; +import org.apache.log4j.PropertyConfigurator; import org.mortbay.thread.ThreadPool; /** @@ -53,8 +54,16 @@ import org.mortbay.thread.ThreadPool; */ public abstract class AbstractCassandraDaemon implements CassandraDaemon { - private static Logger logger = LoggerFactory - .getLogger(AbstractCassandraDaemon.class); + + //Initialize logging in such a way that it checks for config changes every 10 seconds. + static + { + String config = System.getProperty("log4j.configuration", "log4j-server.properties"); + PropertyConfigurator.configureAndWatch(ClassLoader.getSystemResource(config).getFile(), 10000); + org.apache.log4j.Logger.getLogger(AbstractCassandraDaemon.class).info("Logging initialized"); + } + + private static Logger logger = LoggerFactory.getLogger(AbstractCassandraDaemon.class); protected InetAddress listenAddr; protected int listenPort;