Skip to content

Instantly share code, notes, and snippets.

@tkt028
Created April 28, 2014 07:04
Show Gist options
  • Save tkt028/11363797 to your computer and use it in GitHub Desktop.
Save tkt028/11363797 to your computer and use it in GitHub Desktop.
Get string of current stacktrace in Java
// Get current stack trace in Java
// - http://stackoverflow.com/questions/1069066/get-current-stack-trace-in-java
// - http://stackoverflow.com/questions/944991/is-there-a-way-to-dump-a-stack-trace-without-throwing-an-exception-in-java
// - http://javarevisited.blogspot.com/2013/04/how-to-get-current-stack-trace-in-java-thread.html
import org.apache.commons.lang.exception.ExceptionUtils;
public void testGetListElevesOfClassInEnclassmentForNonViecourante() {
String fullStackTrace = ExceptionUtils.getFullStackTrace(new Throwable("TKT Unit Test"));
System.out.println(fullStackTrace);
}
- Another option
import java.util.Arrays;
Arrays.toString(e.getStackTrace());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment