You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Bill Mitchell (JIRA)" <ji...@apache.org> on 2014/02/18 22:27:21 UTC

[jira] [Updated] (CASSANDRA-6720) Implment support for Log4j DOMConfigurator for Cassandra damon

     [ https://issues.apache.org/jira/browse/CASSANDRA-6720?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bill Mitchell updated CASSANDRA-6720:
-------------------------------------

    Attachment: 2014-02-18-13-45.txt
                2014-02-17-22-05.txt
                2014-02-17-21-05.txt
                2014-02-15.txt

> 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)