logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Stauffer <stauffer.ja...@gmail.com>
Subject Re: Ant, JUnit, and Log4j
Date Wed, 06 Apr 2005 12:46:49 GMT
I don't know if it matters but I use lower case for debug and info:
    <level value="debug"/>

Also adding -Dlog4j.debug might give you better info.

On Apr 6, 2005 7:23 AM, Robert Taylor <robert.taylor@broadsource.com> wrote:
> Greetings,
> 
> I'm somewhat new to log4j and am having trouble getting my logging
> output to print to the console.
> 
> My log4j.xml file is as follows:
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
> 
> <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
>  <layout class="org.apache.log4j.PatternLayout">
>   <param name="ConversionPattern"
>          value="[%d{MMM dd, yyyy h:MM:ss aa zzz}] [%-5p] [%c %x %m]%n"/>
>  </layout>
> </appender>
> 
> <logger name="com.company">
>   <level value="DEBUG" />
>   <appender-ref ref="STDOUT" />
> </logger>
> 
> <root>
>   <level value="ERROR" />
>   <appender-ref ref="STDOUT" />
> </root>
> </log4j:configuration>
> 
> I have some JUnit tests configured to execute in an Ant script.
> My unit tests have the appropriate static data member:
> 
> Private static Logger logger = Logger.getLogger("com.company.MyTest");
> 
> And my logging statements are at the appropriate level:
> Logger.debug("My debug statement");
> 
> I've placed log4j.jar in the compile and runtime classpath in my Ant
> script:
> 
> My JUnit target is defined as such:
> 
> <target name="test.MyTest">
> <junit printsummary="false" haltonfailure="true">
>   <classpath refid="runtime.classpath"/>
>   <classpath>
>     <pathelement path="${build.dir}/library/classes"/>
>     <pathelement path="${src.home}/core/main/com/company/core/testing"/>
>   </classpath>
>   <formatter type="plain"/>
>   <test name=" com.company.MyTest "
>           haltonfailure="yes" todir="${build.dir}/report"/>
> </junit>
> </target>
> 
> Nothing is being printed to the console or the subsequent report file
> generated by JUnit.
> 
> I've tried executing the Ant script and setting the location of the
> log4j.xml file from the command line like so:
>  ant -Dlog4j.configuration=<fully qualified path to log4j.xml file>
> 
> I've also tried using Ant's <sysproperty> element within the <junit>
> task:
> <sysproperty key="log4j.configuration" value="${log4j.xml}"/>
> 
> It is behaving like log4j cannot find the configuration file.
> 
> I know log4j is "working" because I can add the following line of code
> to the unit test class and then I get logging statements printed to the
> report file generated by JUnit.
> 
> BasicConfigurator.configure();
> 
> I've wasted too much time on this, so I thought I would post to the user
> list for some help.
> 
> /robert
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 


-- 
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

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


Mime
View raw message