From e2a17e8fb803445fbdee76b22c4401f48c464e2c Mon Sep 17 00:00:00 2001 From: Simon Kitching Date: Fri, 17 Jun 2005 08:09:22 +0000 Subject: [PATCH] Simplify discovery by using table of classes to check. Also enhance diagnostics a little. There are no functional changes in this patch. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@191107 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/logging/impl/LogFactoryImpl.java | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java b/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java index b5e71cc..b51fa63 100644 --- a/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java +++ b/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java @@ -140,6 +140,21 @@ public class LogFactoryImpl extends LogFactory { "org.apache.commons.logging.Log.allowFlawedHierarchy"; + /** + * The names of classes that will be tried (in order) as logging + * adapters. Each class is expected to implement the Log interface, + * and to throw NoClassDefFound or ExceptionInInitializerError when + * loaded if the underlying logging library is not available. Any + * other error indicates that the underlying logging library is available + * but broken/unusable for some reason. + */ + private static final String[] classesToDiscover = { + "org.apache.commons.logging.impl.Log4JLogger", + "org.apache.commons.logging.impl.Jdk14Logger", + "org.apache.commons.logging.impl.Jdk13LumberjackLogger", + "org.apache.commons.logging.impl.SimpleLog" + }; + // ----------------------------------------------------- Instance Variables @@ -698,27 +713,8 @@ public class LogFactoryImpl extends LogFactory { // No user specified log; try to discover what's on the classpath - // Try Log4j - result = createLogFromClass("org.apache.commons.logging.impl.Log4JLogger", - logCategory, - true); - - if (result == null) { - result = createLogFromClass("org.apache.commons.logging.impl.Jdk14Logger", - logCategory, - true); - } - - if (result == null) { - result = createLogFromClass("org.apache.commons.logging.impl.Jdk13LumberjackLogger", - logCategory, - true); - } - - if (result == null) { - result = createLogFromClass("org.apache.commons.logging.impl.SimpleLog", - logCategory, - true); + for(int i=0; (i