ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Levy Lambert <>
Subject Re: Using Log4J with Ant on Unix
Date Tue, 10 Mar 2009 21:51:22 GMT
Dylan Farre wrote:
> Hi, I am having a problem, using Log4J with Ant on Unix.
> My project runs fine on Win and Unix. On Win, Log4J logs all the debug info
> to a log file for me. On Unix, it does not. It does not give any errors or
> anything. I have checked the obvious things like, does the file exist and
> does the user have permissions to edit it.
> I am able to echo directly to the file from within my Ant project and this
> works fine. On Win my echos and the Log4J info gets into the file, but on
> Unix, only my echos get into the file.
> This is how I invoke Ant in a ksh script:
> #!/usr/bin/ksh BASEDIR=$PWD export BASEDIR ANT_HOME=$BASEDIR/Ant_1.7.0
> export ANT_HOME PATH=$PATH:$ANT_HOME/bin export PATH
> JAVACMD=/usr/jdk/instances/jdk1.5.0/jre/bin/java export JAVACMD #
> The CLASSPATH below was neccessary on Win to get Log4J to work.
> cd / chmod -R 777 $BASEDIR cd $BASEDIR $ANT_HOME/bin/ant -f
> $BASEDIR/build.xml -q -e -listener
> I tried this where the ## is, but it made no difference:
> rm Full_Ant_Log.log touch Full_Ant_Log.log chmod -R 777
> $BASEDIR/Full_Ant_Log.log
> My config Log4J properties file,, is in the
> CLASSPATH=$ANT_HOME/lib/ directory

Uhhm. The directory $ANT_HOME/lib is not on the classpath itself.
Try to use the standard ant script, I think it is possible to pass it a 
listener on the command line.

I would do ant -lib [path to the directory containing] 
-listener [listener class]

I did not try it though

> And it looks like this:
> # Configuration Appender "FILE"
> log4j.appender.FILE=org.apache.log4j.FileAppender
> log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
> log4j.appender.FILE.layout.ConversionPattern=%-5p: %d: %m%n
> log4j.appender.FILE.file=$BASEDIR/Full_Ant_Log.log
> log4j.appender.FILE.threshold=DEBUG # Use Appender "FILE"
> log4j.rootLogger=DEBUG, FILE
> I tried,
> log4j.appender.FILE.file=Full_Ant_Log.log
> instead of
> log4j.appender.FILE.file=$BASEDIR/Full_Ant_Log.log
> But that did not make a difference.
> I am using Ant 1.7.0 and log4j 1.2.15.
> I am using the same downloaded file of Ant 1.7.0 and log4j 1.2.15 for
> Windows and Unix, is this ok?
> Any help will be much appreciated.
> Thanks

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message