tags:

views:

376

answers:

2

Is there a way to make Throwable.printStackTrace(PrintStream s) print more lines, so that I can see beyond the final line of "... 40 more" ?

Thanks, Ben

+6  A: 

You don't need to; that information should be present elsewhere in the stack trace. From the docs of printStackTrace():

Note the presence of lines containing the characters "...". These lines indicate that the remainder of the stack trace for this exception matches the indicated number of frames from the bottom of the stack trace of the exception that was caused by this exception (the "enclosing" exception). This shorthand can greatly reduce the length of the output in the common case where a wrapped exception is thrown from same method as the "causative exception" is caught.

In other words, the "... x more" only appears on a chained exception, and only when the last x lines of the stack trace are already present as part of another chained exception's stack trace.

Michael Myers
A: 

Quick guess at a method for you.

static void printLongerTrace(Throwable t){
    for(StackTraceElement e: t.getStackTrace())
        System.out.println(e);
}
jjnguy