After many attempts to log stack traces I think I've found that for
log4j at any rate
log.error(new Exception("message") just logs the message but
log.error("watch this!", new Exception("message")) logs the stack
trace from the exception.
I had some more changes to TransactionImp so I changed to the latter
style in rev 552073.
thanks
david jencks
On Jun 29, 2007, at 10:29 AM, [EMAIL PROTECTED] wrote:
Author: dwoods
Date: Fri Jun 29 10:29:18 2007
New Revision: 551968
URL: http://svn.apache.org/viewvc?view=rev&rev=551968
Log:
GERONIMO-3259 Correctly log the stack trace in TransactionImpl.java
Modified:
geronimo/server/trunk/modules/geronimo-transaction/src/main/
java/org/apache/geronimo/transaction/manager/TransactionImpl.java
Modified: geronimo/server/trunk/modules/geronimo-transaction/src/
main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/
geronimo-transaction/src/main/java/org/apache/geronimo/transaction/
manager/TransactionImpl.java?view=diff&rev=551968&r1=551967&r2=551968
======================================================================
========
--- geronimo/server/trunk/modules/geronimo-transaction/src/main/
java/org/apache/geronimo/transaction/manager/TransactionImpl.java
(original)
+++ geronimo/server/trunk/modules/geronimo-transaction/src/main/
java/org/apache/geronimo/transaction/manager/TransactionImpl.java
Fri Jun 29 10:29:18 2007
@@ -17,6 +17,9 @@
package org.apache.geronimo.transaction.manager;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.IdentityHashMap;
@@ -709,7 +712,10 @@
// if it isn't a named resource should we really
stop all processing here!
// Maybe this would be better to handle else where
and do we really want to prevent all processing of transactions?
Throwable throwable = new IllegalStateException
("Cannot log transactions as " + committer + " is not a
NamedXAResource.");
- log.error(throwable.printStackTrace());
+ Writer w = new StringWriter();
+ PrintWriter pw = new PrintWriter(w);
+ throwable.printStackTrace(pw);
+ log.error(w.toString());
return committer.toString();
}
}