ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Raymond K. DeCampo" <>
Subject JUnit, ANT, log4j, System.out issue
Date Mon, 21 Mar 2005 14:22:38 GMT

I am experiencing an issue with the combination of ANT, JUnit and
log4j. Here's the situation. The ANT build file uses the <junit>
task. Log4j is configured to print to the console. There are also
times when the unit tests use System.out directly. The problem is
that the log4j statements are not captured by the <junit> as part of
the standard output. The logging statements do appear on the console
when I run the tests. But since they are not captured by <junit>,
they do not appear in the XML files and are lost forever.

I originally posted this message to the JUnit list.  Since then I have 
discovered that if I do not fork the JUnit process everything behaves
as I expect.  Not forking the JUnit process is not really an option,
as there are quite a few unit tests and I run into memory issues.

Here's the ANT target:

<target name="run-test" depends="init,test-setup">
<!-- execute the test -->
<junit fork="yes"
    <classpath refid="test.classpath" />
    <formatter type="xml" />
    <formatter type="plain" usefile="false"/>
    <jvmarg line="${test.jvmargs}" />
    <batchtest fork="yes" todir="${}">
        <fileset dir="${test.src}" >
            <include name="${test.full.includes}" />
            <exclude name="${test.full.excludes}" />

Here's the log4j configuration:

<log4j:configuration debug="false">
<appender name="SYS_OUT" class="org.apache.log4j.ConsoleAppender">
    <param name="Target" value="System.out"/>
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%-5p %c{2} -%m%n"/>

    <level value="INFO"/>
    <appender-ref ref="SYS_OUT"/>

Version information:
[09:19 C:/] ant -version
Apache Ant version 1.6.0 compiled on December 18 2003
log4j 1.2.8
JUnit 3.8.1

If anybody could enlighten me on the subject, I'd appreciate it.


Raymond DeCampo
Software Architect
5010 Campuswood Drive - East Syracuse NY 13057
315.414.9855 x411 || 315-414-9856 f

This electronic transmission contains information from Progressive Software Solutions, Inc.
(d/b/a ProSoft, d/b/a PROMERGENT), which may be company confidential and/or company private.
The information contained herein is intended for the exclusive use of the addressee named
above. If you are not the intended recipient, be aware that any disclosure, copying, distribution
or use of this information is prohibited. If you have received this electronic mail transmission
in error, please notify us by telephone or by electronic mail.

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

View raw message