> Is there a way to print a stack trace to the log, when > an exception is passed to say Category.error()?
Yes. See the javadoc for org.apache.log4j.or.ObjectRenderer. ObjectRenderers let you specify how Log4j will stringify a particular class type when writing it to the log. Of course, the trick is getting the stack trace into a String. It's a drag that java.lang.Throwable does not have a method similar to printStackTrace() that simply returns a String. The workaround is to use a java.io.StringWriter like this: // your exception (more precisely, your Throwable) is in "t". StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter( sw ); t.printStackTrace( pw ); There are cases where exceptions are caught, wrapped in another exception, and then re-thrown. If that comes up in your app, you'll want to see the underlying exception and stack trace in your log as well. If the wrapping exception is part of your app, then the best way is to override the printStackTrace() to do the right thing. When the wrapping exception is from a library you'll have to handle that special case from within your ObjectRenderer like this: if (t instanceof ServletException) { Throwable root = ((ServletException) t).getRootCause(); if (root != null) { String s = extract( root ); sw.write("\nRoot cause:\n" + s ); } } Once you have your ObjectRenderer written, you will need to configure Log4j to use it. Since I am configuring Log4j in an unusual way in my app, I will leave the configuration aspect to you (or another list contributor). Does that all make sense? --mkb -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>