Verbose logging of Java exception (Exception) information
Get more information on exception
The following three methods are all for getting the details of the exception, and perhaps the exception details are returned as strings, preserving the style of the stack heap
Method One:
public static string Getexceptionallinformation (Exception ex) {string sOut = ""; Stacktraceelement[] trace = Ex.getstacktrace (); for (Stacktraceelement s:trace) {sOut + = "\tat" + S + "\ r \ n"; } return sOut; }
Method Two:
Public static string getexceptionallinformation_01 (Exception ex) { bytearrayoutputstream out = new bytearrayoutputstream ( ); printstream pout = new printstream (out); ex.printstacktrace (pout); string ret = new string (Out.tobytearray ()); pout.close (); Try { out.close (); } catch (exception e) { } return ret; }
Method Three:
private static String tostring_02 (Throwable e) {stringwriter SW = new StringWriter (); PrintWriter pw = new PrintWriter (SW, True); E.printstacktrace (PW); Pw.flush (); Sw.flush (); return sw.tostring (); }
Verbose logging of Java exception (Exception) information