I need to write small a log analyzer application to process some log files generated by a 3rd party closed source library (having custom logger inside) used in my project. <
here is an explanation of the 'caused by' and '... n more' lines in the printed trace. see also the JavaDoc for printStackTrace. you might not have any work to do.
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.
May be you can try to iterate over the array returned by :
Thread.currentThread().getStackTrace();
Can't you do something with Thread.currentThread().getStackTrace()
?
Here's a real simple example which calls a method recursively 20 times and then dumps out the stack of the current thread.
public class Test {
public static void main(String[] args) {
method();
}
static int x = 0;
private static void method() {
if(x>20) {
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
for(int i=0; i<elements.length; i++) {
System.out.println(elements[i]);
}
}
else {
x++;
method();
}
}
}