jvm arg to make StackTrace be smaller (java)

There is an easy way to make JVM to log smaller stack trace in most of the cases the stack trace have the most useful information in the very first few lines, so there is no need to print it all.
Also printing the complete stack trace will make bigger logs on you server.

Just need to add the following XX arg to your jvm:

-XX:MaxJavaStackTraceDepth=5

The depth depends on you, I made it 5, but it can be what you want, the default is 1024.

And the results will be as the below image:



Here is the definition of this XX arg:


MaxJavaStackTraceDepthMax. no. of lines in the stack trace for Java exceptions (0 means all).
With Java > 1.6, value 0 really means 0. value -1 or any negative number must be specified to print all the stack (tested with 1.6.0_22, 1.7.0 on Windows).
With Java <= 1.5, value 0 means everything, JVM chokes on negative number (tested with 1.5.0_22 on Windows).

And you can find a list of all the XX args that can be added to jvm: http://stas-blogspot.blogspot.mx/2011/07/most-complete-list-of-xx-options-for.html#MaxJavaStackTraceDepth







Comments