users@glassfish.java.net

Re: slf4j - glassfish includes org.slf4j.impl.JDK14LoggerFactory

From: <glassfish_at_javadesktop.org>
Date: Wed, 06 Jan 2010 10:15:03 PST

Thanks Sahoo

It appears to be a bug in Logback. Logback wasn't picking up its logback.xml configuration file and was instead using a default BasicConfiguration.

Logback fails to locate the logback.xml via classLoader.getResource("logback.xml") because of the way it retrieves the ClassLoader

  public static ClassLoader getClassLoaderOfClass(Class clazz) {
    ClassLoader cl = clazz.getClassLoader();
    if (cl == null) {
      return ClassLoader.getSystemClassLoader();
    } else {
      return cl;
    }
  }

 with clazz = ch.qos.logback.classic.util.ContextInitializer

Since ContextInitializer is in a ear library the code returns a EarLibClassLoader instead of a EarClassLoader.

Should the EarLibClassLoader also delegate to the EarClassLoader or should logback be using Thread.currentThread().getContextClassLoader() ?
[Message sent by forum member 'dwsmith75' (dsmith_at_nesmi.com)]

http://forums.java.net/jive/thread.jspa?messageID=379078