privatestatic Logger puppetLogger = Logger.getLogger("myLogger");
catch (IOException e) {
// e.printStackTrace();
//puppetLogger.error(e);
puppetLogger.error(e.getMessage(),e);
}
puppetLogger.error(e.getMessage(),e);
这样就能打印出StackTrace的信息
ERROR 2014-03-26 12:13:42,552 main Connection refused
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
puppetLogger.error(e);
这样只能答应出简单的exception信息
ERROR 2014-03-26 12:13:42,490 main Connection refused
本文出自 “H2O's运维&开发路” 博客,转载请与作者联系!