Skip to content

Instantly share code, notes, and snippets.

@moser
Created October 21, 2010 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moser/638814 to your computer and use it in GitHub Desktop.
Save moser/638814 to your computer and use it in GitHub Desktop.
Print the current stack trace
public void printCurrentStackTrace() {
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
for(int i= 2; i < elements.length; i++) { //2 to remove Thread#getStackTrace and this method
System.out.println(elements[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment