ripper234 ripper234 - 1 year ago 147
Java Question

Get current stack trace in Java

How do I get the current stack trace in Java, like how in .NET you can do


is not what I want - I want to get the stack trace back, not print it out.

Answer Source

You can use Thread.currentThread().getStackTrace().

That returns an array of StackTraceElements that represent the current stack trace of a program.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download