cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nikolai Grigoriev (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CASSANDRA-6720) Implment support for Log4j DOMConfigurator for Cassandra damon
Date Tue, 18 Feb 2014 18:48:20 GMT
Nikolai Grigoriev created CASSANDRA-6720:
--------------------------------------------

             Summary: Implment support for Log4j DOMConfigurator for Cassandra damon
                 Key: CASSANDRA-6720
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-6720
             Project: Cassandra
          Issue Type: Improvement
          Components: Config, Core
            Reporter: Nikolai Grigoriev
            Priority: Trivial


Currently CassandraDaemon explicitly uses PropertyConfigurator to load log4j settings if "log4j.defaultInitOverride"
is set to true, which is done by default. This does not allow to use log4j XML configuration
file because it requires using of DOMConfigurator, in the similar fashion. The only way to
use it is to change the value of  "log4j.defaultInitOverride" property in the startup script.

Here is the background why I think it might be useful to support the XML configuration, even
if you hate XML ;)

I wanted to ship my Cassandra logs to Logstash and I have been using SocketAppender. But then
I have discovered that any issue with Logstash log4j server result in significant performance
degradation for Cassandra as the logger blocks. I was able to easily reproduce the problem
with a separate test. It seems that the obvious solution was to use AsyncAppender before SocketAppender,
that eliminates the blocking. However, AsyncAppender can be only confgured via DOMConfigurator,
at least in Log4j 1.2.

I think it does not hurt to make a little change to support both configuration types, in a
way similar to Spring's Log4jConfigurer:

{code}
	public static void initLogging(String location, long refreshInterval) throws FileNotFoundException
{
		String resolvedLocation = SystemPropertyUtils.resolvePlaceholders(location);
		File file = ResourceUtils.getFile(resolvedLocation);
		if (!file.exists()) {
			throw new FileNotFoundException("Log4j config file [" + resolvedLocation + "] not found");
		}
		if (resolvedLocation.toLowerCase().endsWith(XML_FILE_EXTENSION)) {
			DOMConfigurator.configureAndWatch(file.getAbsolutePath(), refreshInterval);
		}
		else {
			PropertyConfigurator.configureAndWatch(file.getAbsolutePath(), refreshInterval);
		}
	}

I would be happy to submit the change unless there are any objections.
{code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message