logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "wleana" <wle...@yahoo.com>
Subject Re: no log output when invoked from ANT/JUnit
Date Wed, 02 Apr 2003 19:50:19 GMT
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 -
1. You said you need to specify log4j.configuration..But I didn't 
have to specify it, and it works fine...how come?
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?
Thanks a lot.
wleana



--- In Log4J@yahoogroups.com, Erik Price <eprice@p...> wrote:
> 
> 
> wleana wrote:
> > Hi,
> > I have a LogTest program that can successfully write to syslog 
using 
> > Log4J *when I invoke it standalone*, ie. java ***.**.LogTest. But 
> > when I do it from ANT/JUnit, there is no log message written. 
> > 
> > I tried around, and found that if I add the call 
> > PropertyConfigurator.configure("log4j.properties") in my code, 
then 
> > it will write the log message when I run ANT/JUnit.
> > 
> > But why do I need to do it just for ANT/Junit env, while it is 
not 
> > needed when I run it standalone? I don't want to hard code that 
way 
> > in the code.
> > 
> > For the standalone way, I didn't specify log4j.configuration or 
> > invoke PropertyConfigurator.configure(..), all I do is to put 
> > log4j.properties file in my classpath and it works. 
> 
> I do not know for certain but is it possible that you did not have 
the 
> file in your Ant script's <classpath> ?
> 
> I have been using Ant and Log4J with JUnit successfully for the 
past 
> couple of days by doing this:
> 
> 1. I have a file named "testlogconfig.properties" located at some 
> specified point in my source tree.
> 
> 2. I have Ant set a system property with <sysproperty> named 
> "log4j.configuration" whose value is the path to my properties 
file, 
> prepended by the characters: "file://" (so it looks like this:
>      <property name="test.log4j.config"
>            location="path/to/properties/file"/>
>      <junit
>          ...(other attributes go here)...
>            >
>        <sysproperty name="log4j.configuration"
>                    value="file://${test.log4j.config}"/>
>      </junit>
> ).
> 
> 3. Log4J automatically checks for this system property and 
evaluates the 
> value to a URL and searches for the file at that URL.  In my case, 
on 
> Win2k, I had to use the "file://" prefix but I have heard that you 
don't 
> necessarily have to use that on Unix systems.
> 
> Maybe that will help?
> 
> 
> Erik
> 
> 
> --------------------------------------------------------------------
-
> To unsubscribe, e-mail: log4j-user-unsubscribe@j...
> For additional commands, e-mail: log4j-user-help@j...


---------------------------------------------------------------------
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