3

When a AWT/swing application encounters an exception a very long stack trace is printed with lots of unnecessary information. Is there a way to only print the part that is relevant to my code and not everything which has to do with the swing/awt part?

Alexander Simko
  • 183
  • 2
  • 12

1 Answers1

5
  1. If you are catching the Exceptions (which you should be), rather than directly calling printStackTrace() you could manually print (or exclude) each element by getting the StackTraceElements from Throwable.getStackTrace()
  2. If you are using a logging library, you can change the output by changing the output of the library. For example, here's an example with log4j that changes the output
  3. You can fiddle with the -XX:MaxJavaStackTraceDepth JVM option
Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
copeg
  • 8,290
  • 19
  • 28