Author: skitching
Date: Sun Nov 19 00:50:31 2006
New Revision: 476772
URL: http://svn.apache.org/viewvc?view=rev&rev=476772
Log:
Improve diagnostics when underlying lib throws InvocationTargetException.
Patch provided by Lilliane E. Blaze. See Jira issue LOGGING-111.
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/viewvc/jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java?view=diff&rev=476772&r1=476771&r2=476772
==============================================================================
---
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
Sun Nov 19 00:50:31 2006
@@ -908,7 +908,7 @@
if (isDiagnosticsEnabled()) {
logDiagnostic(
"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) {
result = createLogFromClass(classesToDiscover[i], logCategory,
true);
@@ -1362,6 +1362,29 @@
+ logAdapterClassName + "' -- "
+ discoveryFlaw.getClass().getName() + ": "
+ 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) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]