I have to extract the exception and corresponding stack trace starting from a line number in a log file. I know the starting line no of the error. how can i find out where the stack trace will end from the below example? Appreciate your help

<pre>
example
-------
2016-10-07 15:49:07,537 ERROR Some exception
 stacktrace line 1
 stacktrace line 2
 .
 .
 stacktrace line n
2016-10-07 15:49:07,539 debug blah blah blah
2016-10-07 15:49:07,540 debug blah blah blah
</pre>