Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Log4j and JUnit conflict (http://www.velocityreviews.com/forums/t133689-log4j-and-junit-conflict.html)

Paul Carey 05-21-2004 12:43 PM

Log4j and JUnit conflict
 
Hi

I've written a class that extends TestCase and creates a Logger with
the following line:
private static Logger logger = Logger.getLogger( DataTest.class );

If no log4j config file is specified, I get the following errors when
I test DataTest in the awtui.TestRunner:

log4j:WARN No appenders could be found for logger
(poc.database.DataTest).
log4j:WARN Please initialize the log4j system properly.


If a specify a simple config file (below) I get the following errors:

log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not
assignable to a "
org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [junit.runner.TestCaseClassLoader@4aeb52] whereas object
of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
[sun.misc.Launcher$
AppClassLoader@12f6684].
log4j:ERROR Could not instantiate appender named "A1".
log4j:WARN No appenders could be found for logger
(poc.database.DataTest).
log4j:WARN Please initialize the log4j system properly.

If I specify the same config file but run the textui.TestRunner, it
works fine.

It's not much of a problem, but I'd appreciate if anyone could tell me
why this is happening.
Many thanks

Paul

# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternL ayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n


All times are GMT. The time now is 05:44 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.