1
0

Improve diagnostics when underlying lib throws InvocationTargetException.

Patch provided by Lilliane E. Blaze. See Jira issue LOGGING-111.


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@476772 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Simon Kitching
2006-11-19 08:50:31 +00:00
parent fa514dfe30
commit 342bbe7a7a

View File

@@ -908,7 +908,7 @@ public class LogFactoryImpl extends LogFactory {
if (isDiagnosticsEnabled()) { if (isDiagnosticsEnabled()) {
logDiagnostic( logDiagnostic(
"No user-specified Log implementation; performing discovery" + "No user-specified Log implementation; performing discovery" +
" using the standard supported logging implementations..."); " using the standard supported logging implementations...");
} }
for(int i=0; (i<classesToDiscover.length) && (result == null); ++i) { for(int i=0; (i<classesToDiscover.length) && (result == null); ++i) {
result = createLogFromClass(classesToDiscover[i], logCategory, true); result = createLogFromClass(classesToDiscover[i], logCategory, true);
@@ -1362,6 +1362,29 @@ public class LogFactoryImpl extends LogFactory {
+ logAdapterClassName + "' -- " + logAdapterClassName + "' -- "
+ discoveryFlaw.getClass().getName() + ": " + discoveryFlaw.getClass().getName() + ": "
+ discoveryFlaw.getLocalizedMessage()); + discoveryFlaw.getLocalizedMessage());
if (discoveryFlaw instanceof InvocationTargetException ) {
// Ok, the lib is there but while trying to create a real underlying
// logger something failed in the underlying lib; display info about
// that if possible.
InvocationTargetException ite = (InvocationTargetException)discoveryFlaw;
Throwable cause = ite.getTargetException();
if (cause != null) {
logDiagnostic("... InvocationTargetException: " +
cause.getClass().getName() + ": " +
cause.getLocalizedMessage());
if (cause instanceof ExceptionInInitializerError) {
ExceptionInInitializerError eiie = (ExceptionInInitializerError)cause;
Throwable cause2 = eiie.getException();
if (cause2 != null) {
logDiagnostic("... ExceptionInInitializerError: " +
cause2.getClass().getName() + ": " +
cause2.getLocalizedMessage());
}
}
}
}
} }
if (!allowFlawedDiscovery) { if (!allowFlawedDiscovery) {