[
https://issues.apache.org/jira/browse/CASSANDRA-2383?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13056826#comment-13056826
]
David Allsopp edited comment on CASSANDRA-2383 at 7/2/11 10:22 AM:
-------------------------------------------------------------------
Suggested fix for AbstractCassandraDaemon static initializer (apologies -
haven't got a suitable version of diff on this windows box yet). Untested on
linux as yet.
{noformat}
//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");
URL configLocation = null;
try
{
// try loading from a physical location first.
configLocation = new URL(config);
}
catch (MalformedURLException ex)
{
// then try loading from the classpath.
configLocation =
AbstractCassandraDaemon.class.getClassLoader().getResource(config);
}
if (configLocation == null)
throw new RuntimeException("Couldn't figure out log4j
configuration: "+config);
// Now convert URL to a filename
String configFileName = null;
try
{
// first try URL.getFile() which works for opaque URLs
(file:foo) and paths without spaces
configFileName = configLocation.getFile();
File configFile = new File(configFileName);
// then try alternative approach which works for all
hierarchical URLs with or without spaces
if(!configFile.exists())
{
configFileName = new
File(configLocation.toURI()).getCanonicalPath();
}
}
catch (Exception e)
{
throw new RuntimeException("Couldn't convert log4j
configuration location to a valid file.", e);
}
PropertyConfigurator.configureAndWatch(configFileName, 10000);
org.apache.log4j.Logger.getLogger(AbstractCassandraDaemon.class).info("Logging
initialized");
}
{noformat}
was (Author: dallsopp):
Suggested fix for AbstractCassandraDaemon static initializer (apologies -
haven't got a suitable version of diff on this windows box yet). Untested on
linux as yet.
{noformat}
//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");
URL configLocation = null;
try
{
// try loading from a physical location first.
configLocation = new URL(config);
}
catch (MalformedURLException ex)
{
// load from the classpath.
configLocation =
AbstractCassandraDaemon.class.getClassLoader().getResource(config);
}
if (configLocation == null)
throw new RuntimeException("Couldn't figure out log4j
configuration: "+config);
String configFileName = null;
try
{
configFileName = new
File(configLocation.toURI()).getCanonicalPath();
}
catch (Exception e)
{
throw new RuntimeException("Couldn't convert log4j
configuration location to a valid file.", e);
}
PropertyConfigurator.configureAndWatch(configFileName, 10000);
org.apache.log4j.Logger.getLogger(AbstractCassandraDaemon.class).info("Logging
initialized");
}
{noformat}
> 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