Log4j and JUnit conflict

Discussion in 'Java' started by Paul Carey, May 21, 2004.

  1. Paul Carey

    Paul Carey Guest

    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.PatternLayout
    log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
     
    Paul Carey, May 21, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexandra Stehman

    eclipse, junit, log4j, & finding log4j.xml

    Alexandra Stehman, Jan 19, 2004, in forum: Java
    Replies:
    0
    Views:
    5,860
    Alexandra Stehman
    Jan 19, 2004
  2. BlueDolphin

    log4j and console in ANT/JUnit task

    BlueDolphin, Oct 21, 2004, in forum: Java
    Replies:
    6
    Views:
    10,311
    BlueDolphin
    Oct 23, 2004
  3. nospawn
    Replies:
    2
    Views:
    1,186
    Giovanni Azua
    Feb 3, 2006
  4. Martijn

    eclipse junit version conflict

    Martijn, Apr 11, 2007, in forum: Java
    Replies:
    0
    Views:
    419
    Martijn
    Apr 11, 2007
  5. charles cashion

    css conflict (or html conflict)

    charles cashion, Feb 18, 2009, in forum: HTML
    Replies:
    2
    Views:
    823
    charles cashion
    Feb 18, 2009
Loading...

Share This Page