`

使用StringWriter获取异常内容

阅读更多
try{...} catch (Exception e) {
		e.printStackTrace();
		rspCode = String.valueOf(BaseException.RSP_SYS_ERROR_CODE);
		try {
			// TODO 发送邮件预警
			StringWriter sw = new StringWriter();  
	        e.printStackTrace(new PrintWriter(sw, true));  
	        String str = sw.toString();  
		    String text = "账户: " + account + ", 代码: " + rspCode + "<br> 信息: " + str;
		    emailService.sendBatchMail(MailUtil.mailto, "warning", text, "登录失败预警");
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		} finally { ...}


  • 大小: 50.7 KB
1
0
分享到:
评论
1 楼 eisenwolf 2013-12-12  
  很实用~~

相关推荐

Global site tag (gtag.js) - Google Analytics