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
This commit is contained in:
@@ -140,6 +140,21 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
"org.apache.commons.logging.Log.allowFlawedHierarchy";
|
"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
|
// ----------------------------------------------------- Instance Variables
|
||||||
|
|
||||||
@@ -698,27 +713,8 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
|
|
||||||
// No user specified log; try to discover what's on the classpath
|
// No user specified log; try to discover what's on the classpath
|
||||||
|
|
||||||
// Try Log4j
|
for(int i=0; (i<classesToDiscover.length) && (result == null); ++i) {
|
||||||
result = createLogFromClass("org.apache.commons.logging.impl.Log4JLogger",
|
result = createLogFromClass(classesToDiscover[i], logCategory, true);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
@@ -910,9 +906,17 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
+ logAdapterClassName);
|
+ logAdapterClassName);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
this.logMethod = null;
|
this.logMethod = null;
|
||||||
logDiagnostic(logAdapterClassName + " does not declare method "
|
logDiagnostic(
|
||||||
|
"info:" + logAdapterClassName
|
||||||
|
+ " from classloader " + objectId(currentCL)
|
||||||
|
+ " does not declare optional method "
|
||||||
+ "setLogFactory(LogFactory)");
|
+ "setLogFactory(LogFactory)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logDiagnostic(
|
||||||
|
"Log adapter " + logAdapterClassName
|
||||||
|
+ " from classloader " + objectId(currentCL)
|
||||||
|
+ " has been selected for use.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return logAdapter;
|
return logAdapter;
|
||||||
|
|||||||
Reference in New Issue
Block a user