How do I capture an exception stack trace and put it into a string?
Created Dec 3, 2001
Luigi Viggiano Here's how to print the trace in a string:
Luigi
Exception ex = new Exception("something went wrong");
StringWriter sw = new StringWriter();
ex.printStackTrace(new PrintWriter(sw));
String stacktrace = sw.toString();
System.out.println("stacktrace = " + stacktrace);
HTH.Luigi