logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Price <epr...@ptc.com>
Subject Re: no log output when invoked from ANT/JUnit
Date Wed, 02 Apr 2003 20:15:59 GMT


wleana wrote:
> You are right, I don't have the directory in the ANT's class path, 
> but nevertheless, ANT can find those classes under it...I have two 
> things that need to be clarified -

If I am not mistaken, does not Ant inherit your $CLASSPATH environment 
variable as the Ant property named "java.class.path"?  So it /might/ 
have been in Ant's classpath without you having known about it, but I 
haven't seen your ant script so I'm not sure.

> 1. You said you need to specify log4j.configuration..But I didn't 
> have to specify it, and it works fine...how come?

If you don't specify a System property named "log4j.configuration", then 
by default Log4J initializes its "resource" variable to the string 
"log4j.properties".  Log4J then creates a URL from this string and 
attempts to resolve it, and uses the file at that URL as the 
configuration file.  If it cannot create a URL from it, then Log4J 
searches through the current class loader's class path for a file with 
that name.  Perhaps it was somehow finding your log4j.properties file -- 
try renaming it to something else and see if it still works.

> 2. Is there a way to specify a default configuration programmatically 
> (ie. in the code, specify the Appender, Layout, etc...) and make it 
> picked-up if the log4j.properties is not found?  Since i don't even 
> explicitly call PropertyConfigurator.configure in my code, how can 
> this kind of fall-back logic be implemented?

Well, you could always put that programmatic configuration inside of an 
if-block which checks to see if "log4j.configuration" system property is 
set... but this sounds an awful lot like what Log4J does by default.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Mime
View raw message