Erik Price wrote:
Hi,

I'm having trouble with my first excursion into Log4J. I'm using an Ant script to compile my project and then call JUnit tests. I have no logging statements in the JUnit tests, but I do have logging statements in my application. I have confirmed (via System.out.print) that there is a System Property whose key is "log4j.configuration", and that this is a valid file on my Win2k/Cygwin filesystem, and the contents of that file are as follows:

[...]


Does anyone see some problem with my log4j.configuration Properties file that would cause the Default Initialization to fail with the message that it can't find an Appender? It works fine when my Properties file is in my classpath, but according to the docs, this should work fine if I am passing in the log4j.configuration System Property, which I am.

Forgive me for responding to my own post, but I think I've found the answer and hopefully this might help someone else down the road. However, if I'm mistaken or someone can confirm for me that I'm -not- mistaken, that would be awesome.


It seems that it had nothing to do with my log4j.properties file, which makes sense since it worked fine if I just let the default initialization pick it up from the class loader's path (i.e., by not specifying a "log4j.configuration" System Property). However, apparently on Windows a file path does not translate directly to a URL. The short manual on the Log4J site explicitly states:

  <quote>
    2. Set the resource string variable to the value of the
    log4j.configuration system property. The preferred way to
    specify the default initialization file is through the
    log4j.configuration system property. In case the system
    property log4j.configuration is not defined, then set the
    string variable resource to its default value
    "log4j.properties".

    3. Attempt to convert the resource variable to a URL.
  </quote>

What worked for me was changing the value of the "log4j.configuration" System Property from a simple Windows file path to "file://" + a simple Windows file path.

Is this the way it's supposed to work? I just want to make sure so that I don't continue to develop under a mistaken impression, because the above evaluates to an invalid URL (file://D:\User Profiles\eprice\My Documents\dev\java\projectname).

I can use Ant to manipulate that string to use proper (Unix/Java-style) path format, and will do so if anyone can clear me up on this.

Thanks,

Erik


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to