0

Possible Duplicate:
howto increase lines of java stack trace dump?

I'm writing a Java Application for tomcat. whenever an Exception is being thrown I get the name of the Exception and the stack trace and in the end if it's a long trace I get ... X more.

how can I configure tomcat to show a full stack trace ?

thank you!

Community
  • 1
  • 1
ufk
  • 30,912
  • 70
  • 235
  • 386

1 Answers1

3

That's not Tomcat's fault, it's the way the Throwable.printStackTraceAsCause(PrintStream s, StackTraceElement[] causedTrace) method implements the printing of stacktraces.

 /**
     * Print our stack trace as a cause for the specified stack trace.
     */
    private void printStackTraceAsCause(PrintStream s,
                                        StackTraceElement[] causedTrace)
    {
        // assert Thread.holdsLock(s);

        // Compute number of frames in common between this and caused
        StackTraceElement[] trace = getOurStackTrace();
        int m = trace.length-1, n = causedTrace.length-1;
        while (m >= 0 && n >=0 && trace[m].equals(causedTrace[n])) {
            m--; n--;
        }
        int framesInCommon = trace.length - 1 - m;

        s.println("Caused by: " + this);
        for (int i=0; i <= m; i++)
            s.println("\tat " + trace[i]);
        if (framesInCommon != 0)
            s.println("\t... " + framesInCommon + " more");

        // Recurse if we have a cause
        Throwable ourCause = getCause();
        if (ourCause != null)
            ourCause.printStackTraceAsCause(s, trace);
    }

If you want, you can print your stacktraces yourself in a log file (or response.getOutputStream()) by getting first displaying the message of the caught element and then displaying the array element of StackTraceElement (which can be found by calling Throwable.getStackTrace() method).

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228