Ok. I know what goes wrong now.
For debug log4j with ant, it is jvmarg instead of arg needed to be
added within java tag.
<java ...>
<jvmarg value="-Dlog4j.debug" />
</java>
log4j.properties is not read because there is another project which
also uses log4j logging system that I was not aware of. And that
classpath property is preceded before my log4j.properties.
Wrong classpath
<path id="spider.classpath">
<fileset dir="${another.project.home}/" includes="**/*.jar"/>
<!-- this includes jars which contains other log4j.properties -->
<pathelement location="${myporject.conf}"/> <!-- my log4j.properties
here then is ignored -->
</path>
Worked version
<path id="spider.classpath">
<pathelement location="${myproject.conf}"/> <!-- make my project's
log4j.properties the first one in classpath -->
....
</path>
Now everything works well.
Thanks.
On Wed, Feb 23, 2011 at 4:27 PM, Thomas Anderson
<[email protected]> wrote:
> I have a build.xml file which will read log4j.properties, stored in
> conf, from conf and log message to another dir e.g. logs/file.log
>
> My build file's classpath points to conf and then when launch the
> application it will have classpath provided.
>
> <path id="myapp.classpath">
> ...
> <pathelement location="${spider.conf}"/>
> ...
> </path>
>
> And in target run, it provides with classpath
>
> <target name="run" depends="clean,package">
> <java fork="true" classname="...">
> <classpath>
> <path refid="myapp.classpath"/>
> <path location="${project.jar}"/>
> </classpath>
> <arg line="-Dlog4j.debug"/>
> </java>
> </target>
>
>
> The content of log4j.properties
>
> log4j.rootLogger = DEBUG, RRX
>
> log4j.rootLogger = INFO, LOGFILE
>
> log4j.appender.LOGFILE=org.apache.log4j.FileAppender
> log4j.appender.LOGFILE.File=message.log
> log4j.appender.LOGFILE.layout=org.apache.log4j.Pattern Layout
> log4j.appender.LOGFILE.layout.ConversionPattern=%d %-5p %c - %m%n
>
> However, it seems ant does not read log4j.properties so no message is
> written to file.
>
> I supply ant with -Dlog4j.debug in the target run or in command line
> directly e.g. ant run -Dlog4j.debug, but there is no different. How
> can I check if log4j property is read from config or not? Or how to
> fix this problem?
>
> Thanks.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]