Re: Dueling Loggers?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Mar 17 2004 - 23:22:28 EST

  • Next message: Mike Kienenberger: "Re: Dueling Loggers?"

    Hi Mike,

    Nested ClassLoaders do introduce lots of uncertainty. Here is a few
    things to try.

    1. Suppress Cayenne logging configuration from happening at some point
    on startup:

        
    org.objectstyle.cayenne.conf.Configuration.setLoggingConfigured(true);

    2. (the opposite of [1]) Explicitly trigger Cayenne logging
    configuration to happen as early as possible. Cayenne's own unit tests
    with JUnit are set up this way - the code below is executed from within
    the static code block in a common TestCase superclass:

        org.objectstyle.cayenne.conf.Configuration.configureCommonLogging();

    It all looks like black magic, but like I said, this is what you get
    with multiple ClassLoaders. I hope one or another approach may give you
    the results you want.

    Andrus

    On Mar 17, 2004, at 5:56 PM, Mike Elliott wrote:
    > I get the following message when I try to run a simple JUnit which
    > utilizes cayenne:
    >
    > 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.TestCaseClassLoade..5575e0] whereas object
    > of type
    > log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
    > [sun.misc.Launcher$AppClassLoade..36228].
    > log4j:ERROR Could not instantiate appender named "A1".
    >
    > Note: I'm not trying to use the logging facility at all. It appears
    > that cayenne wants to do it one way and JUnit wants to do it a
    > different way, and since the two of them don't agree the program
    > simply blows up and refuses to do anything.
    >
    > Is there a way around this?
    >
    >



    This archive was generated by hypermail 2.0.0 : Wed Mar 17 2004 - 23:22:32 EST