Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0101D67AD for ; Tue, 28 Jun 2011 21:25:53 +0000 (UTC) Received: (qmail 97047 invoked by uid 500); 28 Jun 2011 21:25:52 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 96930 invoked by uid 500); 28 Jun 2011 21:25:52 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 96897 invoked by uid 99); 28 Jun 2011 21:25:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jun 2011 21:25:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jun 2011 21:25:50 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id C28BF413078 for ; Tue, 28 Jun 2011 21:25:30 +0000 (UTC) Date: Tue, 28 Jun 2011 21:25:30 +0000 (UTC) From: "David Allsopp (JIRA)" To: commits@cassandra.apache.org Message-ID: <1738198591.141.1309296330793.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <646954741.10620.1301026145736.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Issue Comment Edited] (CASSANDRA-2383) log4j unable to load properties file from classpath MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CASSANDRA-2383?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13056794#comment-13056794 ] David Allsopp edited comment on CASSANDRA-2383 at 6/28/11 9:24 PM: ------------------------------------------------------------------- OK, have gone around in circles a bit on this! -Dlog4j.defaultInitOverride enables AbstractCassandraDaemon to take charge of the log4j configuration in order to make it dynamic (you can change the log4j config file, and it should be updated using the log4j PropertyConfigurator every 10 seconds). The default value of log4j.configuration in the code and in the batch file is "log4j-server.properties", which is not a valid URL, so we drop into: {noformat} configLocation = AbstractCassandraDaemon.class.getClassLoader().getResource(config);{noformat} as you said before. This *does* detect the correct file from CASSANDRA_HOME/conf, since log4j logs the *full path* even though we only supply the filename "log4j-server.properties": {noformat} log4j: [/C:/Users/David/Key%20Value/apache-cassandra-0.7.6-2/conf/log4j-server.properties] does not exist.{noformat} getResource() returns a URL. Converting this to a file using getFile() works fine when there are no spaces; one can verify that the file exists (File.exists() == true). If there are spaces, then this conversion produces a filename that includes the %20 encoding for spaces - this is an incorrect filename. We need instead to convert using: {noformat} new File(configLocation.toURI());{noformat} (with appropriate exception handling for URISyntaxException) which produces a filename with spaces rather than %20. was (Author: dallsopp): OK, have gone around in circles a bit on this! -Dlog4j.defaultInitOverride enables AbstractCassandraDaemon to take charge of the log4j configuration in order to make it dynamic (you can change the log4j config file, and it should be updated using the log4j PropertyConfigurator every 10 seconds). The default value of log4j.configuration in the code and in the batch file is "log4j-server.properties", which is not a valid URL, so we drop into: {noformat} configLocation = AbstractCassandraDaemon.class.getClassLoader().getResource(config); {noformat} as you said before. This *does* detect the correct file from CASSANDRA_HOME/conf, since log4j logs the *full path* even though we only supply the filename "log4j-server.properties": {noformat} log4j: [/C:/Users/David/Key%20Value/apache-cassandra-0.7.6-2/conf/log4j-server.properties] does not exist. {noformat} getResource() returns a URL. Converting this to a file using getFile() works fine when there are no spaces, and you can verify that the file exists. If there are spaces, then this conversion produces a filename that includes the %20 encoding for spaces - this is an incorrect filename. We need instead to convert using: {noformat} new File(configLocation.toURI()); {noformat} (with appropriate exception handling for URISyntaxException) which produces a filename with spaces rather than %20. > log4j unable to load properties file from classpath > --------------------------------------------------- > > Key: CASSANDRA-2383 > URL: https://issues.apache.org/jira/browse/CASSANDRA-2383 > Project: Cassandra > Issue Type: Bug > Components: Tools > Affects Versions: 0.7.4 > Environment: OS : windows > java : 1.6.0.23 > Reporter: david lee > Assignee: T Jake Luciani > Priority: Minor > Fix For: 0.7.7 > > > when cassandra home folder is placed inside a folder which has space characters in its name, > log4j settings are not properly loaded and warning messages are shown. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira