From 0c12cec132cace71dfeec5f2d6a1b42c6ef321be Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Wed, 20 Feb 2013 11:39:42 +0000 Subject: [PATCH] [LOGGING-138] Add stacktrace of discovery failure to diagnostic message. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/logging/trunk@1448097 13f79535-47bb-0310-9956-ffa450edef68 --- src/changes/changes.xml | 4 ++++ .../org/apache/commons/logging/impl/LogFactoryImpl.java | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 1faed83..93013e4 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -44,6 +44,10 @@ The type attribute can be add,update,fix,remove. + + In case of a discovery failure now also the stacktrace of the cause will be + added to the diagnostic message. + Jdk14Logger now correctly uses the specified logger name. diff --git a/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java b/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java index 4acf58d..7d4d545 100644 --- a/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java +++ b/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java @@ -17,6 +17,8 @@ package org.apache.commons.logging.impl; +import java.io.PrintWriter; +import java.io.StringWriter; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -1272,9 +1274,9 @@ public class LogFactoryImpl extends LogFactory { ExceptionInInitializerError eiie = (ExceptionInInitializerError)cause; Throwable cause2 = eiie.getException(); if (cause2 != null) { - logDiagnostic("... ExceptionInInitializerError: " + - cause2.getClass().getName() + ": " + - cause2.getLocalizedMessage()); + final StringWriter sw = new StringWriter(); + cause2.printStackTrace(new PrintWriter(sw, true)); + logDiagnostic("... ExceptionInInitializerError: " + sw.toString()); } } }