views:

29

answers:

1

I am using JBoss 4.2.

Long stack traces are useless to me most of the time. Is there a way to only show the error message? Can stack traces be disabled or trimmed for normal java programs also?

A: 

You may want to just log myException.getMessage(), instead of using myException.printStackTrace() or something similar.

In web servlets, often the whole stack trace isn't that useful because the error is in your own code, i.e. the top several calls, and the rest of the stack is almost always the same servlet framework calls. Given the rest of the request data, it may not be very useful.

But, there is still occasionally value in the full stack trace. For instance, if you ever suspect that a bug in JBoss is causing your application to fail, you will probably need the full trace to track it down. So, rather than just reading logs directly, consider using a log-viewing application that can show and hide details. Log viewers typically let you filter by error level or search terms too. Google App Engine has a good one. I suggest you see what JBoss has to offer (if you don't know already -- I have no idea personally) and then check for third-party alternatives.

Kevin Conner
Thanks for your help Kevin. I looked up what was available for JBoss and found the JBoss Server Log View in Eclipse with the JBoss AS Eclipse plugin. It gives a summary of key warning and errors in a tree view.
reckoner
My pleasure. If you accept my answer, would you mind clicking the green check? Welcome to stackoverflow.com :)
Kevin Conner