1
0

* Log the classloader that really loaded the adapter class, rather than the one

we called loadClass on.
* Remove some debug code accidentally committed recently.


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@394649 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Simon Kitching
2006-04-17 09:16:28 +00:00
parent cfb31332a1
commit fea8fb4449

View File

@@ -967,7 +967,10 @@ public class LogFactoryImpl extends LogFactory {
+ objectId(currentCL)); + objectId(currentCL));
try { try {
if (isDiagnosticsEnabled()) { if (isDiagnosticsEnabled()) {
// show exactly where we are loading this class from. // Show the location of the first occurrence of the .class file
// in the classpath. This is the location that ClassLoader.loadClass
// will load the class from -- unless the classloader is doing
// something weird.
URL url; URL url;
String resourceName = logAdapterClassName.replace('.', '/') + ".class"; String resourceName = logAdapterClassName.replace('.', '/') + ".class";
if (currentCL != null) { if (currentCL != null) {
@@ -983,18 +986,6 @@ public class LogFactoryImpl extends LogFactory {
} }
} }
// hack
{
String l4jCategory = "org.apache.log4j.Category";
String l4jResource = l4jCategory.replace('.', '/') + ".class";
URL l4jUrl = currentCL.getResource(l4jResource);
if (l4jUrl == null) {
logDiagnostic("log4j not found:" + l4jResource);
} else {
logDiagnostic("log4j found:" + l4jUrl);
}
}
Class c = null; Class c = null;
try { try {
c = Class.forName(logAdapterClassName, true, currentCL); c = Class.forName(logAdapterClassName, true, currentCL);
@@ -1030,6 +1021,7 @@ public class LogFactoryImpl extends LogFactory {
break; break;
} }
} }
constructor = c.getConstructor(logConstructorSignature); constructor = c.getConstructor(logConstructorSignature);
Object o = constructor.newInstance(params); Object o = constructor.newInstance(params);
@@ -1043,7 +1035,6 @@ public class LogFactoryImpl extends LogFactory {
break; break;
} }
// Oops, we have a potential problem here. An adapter class // Oops, we have a potential problem here. An adapter class
// has been found and its underlying lib is present too, but // has been found and its underlying lib is present too, but
// there are multiple Log interface classes available making it // there are multiple Log interface classes available making it
@@ -1127,7 +1118,7 @@ public class LogFactoryImpl extends LogFactory {
logDiagnostic( logDiagnostic(
"Log adapter '" + logAdapterClassName "Log adapter '" + logAdapterClassName
+ "' from classloader " + objectId(currentCL) + "' from classloader " + objectId(logAdapterClass.getClassLoader())
+ " has been selected for use."); + " has been selected for use.");
} }