异常信息处理,精准错误定位
这样在日志里可以更快速的定位
将错误信息输出到日志里
public static void main(String[] args) { try { String aa = ""; System.out.println(aa.substring(3)); } catch (Exception e) { e.printStackTrace(); StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw, true)); String str = sw.toString(); LogDispatcher.info(WayBillService, "[异常] printStackTrace 信息" + str); System.out.println("=========="); System.out.println(str); } }