You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by David Durham <da...@scott.af.mil> on 2004/08/31 17:11:09 UTC

[logging]

For some reason, no log4j log files are being generated when I run a 
JUnit task.

The code is simple enough:

    public static final Log log = LogFactory.getLog(AccountTest.class);

    ...

    log.debug("something");


Here are my Ant targets:

        <!-- Start Unit Test Targets -->
    <target name="tests.compile" depends="application.build,prepare.tests">
        <!-- Compile the test sources -->
        <javac destdir="${tests.classes}" srcdir="${tests.src}">
            <classpath>
                <pathelement path="${classpath}"/>
                <pathelement path="${application.dest.classes}"/>
            </classpath>
        </javac>
    </target>

    <target name="tests.report">
        <!--  If logs were generated, copy to buildTemp  -->
        <move todir="${tests.logs}" overwrite="true">
            <fileset dir="." includes="*.log"/>
        </move>
        <!--  create a unit test report  -->
        <junitreport todir="${tests.reports}">
            <fileset dir="${tests.reports}" includes="TEST-*.xml"/>
            <report format="frames" todir="${tests.reports}/html"/>
        </junitreport>
    </target>

    <target name="tests.run.all" depends="tests.compile" 
description="Executes unit tests.">
            <!-- Execute the unit tests -->
        <junit printsummary="on" failureproperty="testsFailed" >
            <formatter type="xml"/>
            <classpath>
                <pathelement path="${classpath}"/>
                <pathelement path="${application.dest.classes}"/>
                <pathelement path="${tests.classes}"/>
            </classpath>
            <batchtest todir="${tests.reports}">
                <fileset dir="${tests.classes}">
                    <include name="**/*"/>
                </fileset>
            </batchtest>
        </junit>
        <antcall target="tests.report"/>
    </target>
        <!-- End Unit Test Targets -->


Within ${application.dest.classes} is a log4j.properties file.  
${classpath} refers to a bunch of jar files (commons-logging, log4j, 
etc.) and, btw, I do get a Junit report, but no logging and I can't seem 
to write to System.out either.

I'm running Ant from the command line.

Can anyone spot something obviously wrong with this?

I posted this question on the Ant user list, but did not receive a response.  I would post to JUnit, but it's a  yahoo group and I can't get to it from work because of a proxy.  Thanks for any help.


- Dave




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


Re: [logging] log4j, junit, + ant

Posted by David Durham <da...@scott.af.mil>.
robert burrell donkin wrote:

> i'd guess that commons-logging is not picking up log4j and is
> defaulting to printing to system out which is being swallowed by the
> junit task. i can't remember off-hand how to make ant/junit log to
> console but you should be able to find out by reading the manual and
> searching the web. if my guess is right, once you do this you'll see
> the messages.
>
> BTW make sure you log to error since (when commons-logging is
> misconfigured, it's likely that low level messages will be ignored).

Thanks for the help.  As it turns out, commons-logging found a 
log4j.properties in xdoclet-1.2.1.jar before finding my log4j.properties 
file.  I rearranged the classpath a bit and it's working as expected.


- Dave

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


Re: [logging] log4j, junit, + ant

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
i'd guess that commons-logging is not picking up log4j and is 
defaulting to printing to system out which is being swallowed by the 
junit task. i can't remember off-hand how to make ant/junit log to 
console but you should be able to find out by reading the manual and 
searching the web. if my guess is right, once you do this you'll see 
the messages.

BTW make sure you log to error since (when commons-logging is 
misconfigured, it's likely that low level messages will be ignored).

- robert

On 31 Aug 2004, at 16:50, David Durham wrote:

> For some reason, no log4j log files are being generated when I run a 
> JUnit task.
>
> The code is simple enough:
>
>    public static final Log log = LogFactory.getLog(AccountTest.class);
>
>    ...
>
>    log.debug("something");
>
>
> Here are my Ant targets:
>
>        <!-- Start Unit Test Targets -->
>    <target name="tests.compile" 
> depends="application.build,prepare.tests">
>        <!-- Compile the test sources -->
>        <javac destdir="${tests.classes}" srcdir="${tests.src}">
>            <classpath>
>                <pathelement path="${classpath}"/>
>                <pathelement path="${application.dest.classes}"/>
>            </classpath>
>        </javac>
>    </target>
>
>    <target name="tests.report">
>        <!--  If logs were generated, copy to buildTemp  -->
>        <move todir="${tests.logs}" overwrite="true">
>            <fileset dir="." includes="*.log"/>
>        </move>
>        <!--  create a unit test report  -->
>        <junitreport todir="${tests.reports}">
>            <fileset dir="${tests.reports}" includes="TEST-*.xml"/>
>            <report format="frames" todir="${tests.reports}/html"/>
>        </junitreport>
>    </target>
>
>    <target name="tests.run.all" depends="tests.compile" 
> description="Executes unit tests.">
>            <!-- Execute the unit tests -->
>        <junit printsummary="on" failureproperty="testsFailed" >
>            <formatter type="xml"/>
>            <classpath>
>                <pathelement path="${classpath}"/>
>                <pathelement path="${application.dest.classes}"/>
>                <pathelement path="${tests.classes}"/>
>            </classpath>
>            <batchtest todir="${tests.reports}">
>                <fileset dir="${tests.classes}">
>                    <include name="**/*"/>
>                </fileset>
>            </batchtest>
>        </junit>
>        <antcall target="tests.report"/>
>    </target>
>        <!-- End Unit Test Targets -->
>
>
> Within ${application.dest.classes} is a log4j.properties file.  
> ${classpath} refers to a bunch of jar files (commons-logging, log4j, 
> etc.) and, btw, I do get a Junit report, but no logging and I can't 
> seem to write to System.out either.
>
> I'm running Ant from the command line.
>
> Can anyone spot something obviously wrong with this?
>
> I posted this question on the Ant user list, but did not receive a 
> response.  I would post to JUnit, but it's a  yahoo group and I can't 
> get to it from work because of a proxy.  Thanks for any help.
>
>
> - Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


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


[logging] log4j, junit, + ant

Posted by David Durham <da...@scott.af.mil>.
For some reason, no log4j log files are being generated when I run a 
JUnit task.

The code is simple enough:

    public static final Log log = LogFactory.getLog(AccountTest.class);

    ...

    log.debug("something");


Here are my Ant targets:

        <!-- Start Unit Test Targets -->
    <target name="tests.compile" depends="application.build,prepare.tests">
        <!-- Compile the test sources -->
        <javac destdir="${tests.classes}" srcdir="${tests.src}">
            <classpath>
                <pathelement path="${classpath}"/>
                <pathelement path="${application.dest.classes}"/>
            </classpath>
        </javac>
    </target>

    <target name="tests.report">
        <!--  If logs were generated, copy to buildTemp  -->
        <move todir="${tests.logs}" overwrite="true">
            <fileset dir="." includes="*.log"/>
        </move>
        <!--  create a unit test report  -->
        <junitreport todir="${tests.reports}">
            <fileset dir="${tests.reports}" includes="TEST-*.xml"/>
            <report format="frames" todir="${tests.reports}/html"/>
        </junitreport>
    </target>

    <target name="tests.run.all" depends="tests.compile" 
description="Executes unit tests.">
            <!-- Execute the unit tests -->
        <junit printsummary="on" failureproperty="testsFailed" >
            <formatter type="xml"/>
            <classpath>
                <pathelement path="${classpath}"/>
                <pathelement path="${application.dest.classes}"/>
                <pathelement path="${tests.classes}"/>
            </classpath>
            <batchtest todir="${tests.reports}">
                <fileset dir="${tests.classes}">
                    <include name="**/*"/>
                </fileset>
            </batchtest>
        </junit>
        <antcall target="tests.report"/>
    </target>
        <!-- End Unit Test Targets -->


Within ${application.dest.classes} is a log4j.properties file.  
${classpath} refers to a bunch of jar files (commons-logging, log4j, 
etc.) and, btw, I do get a Junit report, but no logging and I can't seem 
to write to System.out either.

I'm running Ant from the command line.

Can anyone spot something obviously wrong with this?

I posted this question on the Ant user list, but did not receive a response.  I would post to JUnit, but it's a  yahoo group and I can't get to it from work because of a proxy.  Thanks for any help.


- Dave



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