diff -ru logback-0.9.5/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java logback-0.9.5.new/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java --- logback-0.9.5/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java 2007-04-02 20:54:59.000000000 +0200 +++ logback-0.9.5.new/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java 2007-04-20 11:26:27.000000000 +0200 @@ -24,26 +24,46 @@ configurator.doConfigure(url); } + public static void autoConfig(LoggerContext loggerContext, URL url) { + if (url != null) { + try { + configureByResource(loggerContext, url); + } catch (JoranException je) { + StatusPrinter.print(loggerContext); + } + } else { + BasicConfigurator.configure(loggerContext); + } + } + public static void autoConfig(LoggerContext loggerContext, ClassLoader classLoader) { URL url = Loader.getResource(TEST_AUTOCONFIG_FILE, classLoader); if (url == null) { url = Loader.getResource(AUTOCONFIG_FILE, classLoader); } - - if (url != null) { - try { - configureByResource(loggerContext, url); - } catch (JoranException je) { - StatusPrinter.print(loggerContext); - } - } else { - BasicConfigurator.configure(loggerContext); + autoConfig(loggerContext, url); + } + + public static URL findResource(ClassLoader classLoader) { + URL url = Loader.getResource(TEST_AUTOCONFIG_FILE, classLoader); + if (url == null) { + url = Loader.getResource(AUTOCONFIG_FILE, classLoader); } + return url; } public static void autoConfig(LoggerContext loggerContext) { - ClassLoader tccl = Loader.getTCL(); - autoConfig(loggerContext, tccl); + ClassLoader ccl = Loader.getCCCL(); + URL url = findResource(ccl); + + if (url == null) { + ClassLoader tcl = Loader.getTCL(); + if (tcl != ccl) { + url = findResource(tcl); + } + } + autoConfig(loggerContext, url); } + } Only in logback-0.9.5.new/logback-classic: target diff -ru logback-0.9.5/logback-core/src/main/java/ch/qos/logback/core/util/Loader.java logback-0.9.5.new/logback-core/src/main/java/ch/qos/logback/core/util/Loader.java --- logback-0.9.5/logback-core/src/main/java/ch/qos/logback/core/util/Loader.java 2007-02-02 20:27:00.000000000 +0100 +++ logback-0.9.5.new/logback-core/src/main/java/ch/qos/logback/core/util/Loader.java 2007-04-20 11:24:22.000000000 +0200 @@ -67,9 +67,9 @@ } public static URL getResourceByTCL(String resource) { - return getResource(resource, getTCL()); - } - + return getResource(resource, getTCL()); + } + /** * Get the Thread Context Loader which is a JDK 1.2 feature. If we are running * under JDK 1.1 or anything else goes wrong the method returns @@ -80,6 +80,15 @@ return Thread.currentThread().getContextClassLoader(); } + /** + * Get the current class Class Loader. If anything goes wrong the method returns + * null. + * + */ + public static ClassLoader getCCCL() { + return Loader.class.getClassLoader(); + } + public static Class loadClass(String clazz, Context context) throws ClassNotFoundException { ClassLoader cl = context.getClass().getClassLoader(); return cl.loadClass(clazz); Only in logback-0.9.5.new/logback-core/src/test: output Only in logback-0.9.5.new/logback-core: target Only in logback-0.9.5.new/logback-core: temp.log Only in logback-0.9.5.new: target