使用log4j的时候如何输出printStackTrace()的堆栈信息
使用log4j的时候如何输出printStackTrace()的堆栈信息
研究了一下发现很简单,如下:
log.error(e.getMessage(),e);
输出信息如下:
2009-05-11 12:40:45 [ Thread-1:2231687 ] - [ ERROR ] Connection reset by peer: socket write error java.net.SocketException: Connection reset by peer: socket write error at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(Unknown Source) at java.net.SocketOutputStream.write(Unknown Source) at java.io.DataOutputStream.write(Unknown Source) at java.io.FilterOutputStream.write(Unknown Source) at com.mythlink.facebook.server.Server.run(Server.java:110) at java.lang.Thread.run(Unknown Source) 其中Connection reset by peer: socket write error 是e.getMessage();所得到的