Author: skitching
Date: Fri Jun 17 01:09:22 2005
New Revision: 191107
URL: http://svn.apache.org/viewcvs?rev=191107&view=rev
Log:
Simplify discovery by using table of classes to check. Also enhance diagnostics
a little.
There are no functional changes in this patch.
Modified:
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
Modified:
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java?rev=191107&r1=191106&r2=191107&view=diff
==============================================================================
---
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
(original)
+++
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
Fri Jun 17 01:09:22 2005
@@ -140,6 +140,21 @@
"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 @@
// 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<classesToDiscover.length) && (result == null); ++i) {
+ result = createLogFromClass(classesToDiscover[i], logCategory,
true);
}
if (result == null) {
@@ -910,9 +906,17 @@
+ logAdapterClassName);
} catch (Throwable t) {
this.logMethod = null;
- logDiagnostic(logAdapterClassName + " does not declare method "
- + "setLogFactory(LogFactory)");
+ logDiagnostic(
+ "info:" + logAdapterClassName
+ + " from classloader " + objectId(currentCL)
+ + " does not declare optional method "
+ + "setLogFactory(LogFactory)");
}
+
+ logDiagnostic(
+ "Log adapter " + logAdapterClassName
+ + " from classloader " + objectId(currentCL)
+ + " has been selected for use.");
}
return logAdapter;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]