Thread.dumpStack()
To print a stack trace in Java, without throwing an exception, call Thread.dumpStack(). The output will go to System.err. This could be redirected to a log file or some other output stream:
PrintStream logFile; // ... System.setErr(logFile); Thread.dumpStack();