You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "David Allsopp (JIRA)" <ji...@apache.org> on 2011/06/28 23:25:30 UTC

[jira] [Issue Comment Edited] (CASSANDRA-2383) log4j unable to load properties file from classpath

    [ 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