Why? Log files are for humans, and the very occasional analysis program. If you are writing any software at all to read log files you are almost certainly doing something wrong already, and if you're searching for a regex to analysis a stack trace at runtime you are 99.999% likely to be barking up the wrong tree.
> How to parse only the stack trace using regex?
From the entire file? I doubt it is possible.
Log files are normally rather large. You would need to read the entire file into memory, then apply a multiline regex which means it is going to be scanning an rescanning multiple times. If it doesn't just die it would probably take a long time.
Better to just build a parser that reads each line and does it.
And of course the given example presumes that NO threads are in use. If they are then the it is not deterministically possible to correctly the parse the file because there is no thread indicator.