log4j异常信息存 入库
关于log4j的配置文件log4j.properties在此不作描述,网上很多资料介绍它的。
?
这里直接给出代码和说明:
log4j.properties
?
?
StringWriter sw = new StringWriter();PrintWriter pw = new PrintWriter(sw); }catch (Exception e) {String exceptionStack = "";e.printStackTrace(pw);exceptionStack = sw.toString();log.error(exceptionStack);}finally{try {pw.close();sw.close();} catch (IOException e) {e.printStackTrace();}}?
?