如何将日志的错误信息打印出来

时间:2024-10-14 07:08:48

1、这里的话我直接给大家代码吧!StringWriter sw = null; PrintWriter pw = null; try { sw = new StringWriter(); pw = new PrintWriter(sw);

如何将日志的错误信息打印出来

2、//将出错的栈信息输出到printWriter中 e.printStackTrace(pw); pw.flush(); sw.flush(); } finally {

如何将日志的错误信息打印出来

3、if (sw != null) { try { sw.close(); } catch (IOException e1) { e1.printStackTrace(); } } if (pw != null) { pw.close(); } }     log.err(sw.toString());

如何将日志的错误信息打印出来

4、log.debug("Request TTL set to: {} ({})", new Date(ttl), ttl); // Request TTL set to: Wed Apr 28 20:14:12 CEST 2010 (1272478452437) 。

如何将日志的错误信息打印出来

5、final String duration = DurationFormatUtils.formatDurationWords(durat足毂忍珩ionMillis, true, true); log.info("Importing took: {}ms ({})", durationMillis, duration); //Importing took: 123456789ms (1 day 10 hours 17 minutes 36 seconds)

如何将日志的错误信息打印出来
© 手抄报圈