/** * apo:around环绕方式记录日志 * * @param jp * @return * @throws Throwable */ public Object saveLoginAndLogic(ProceedingJoinPoint jp) throws Throwable { LogMethod logMethod = LogMethodText(jp); Object ret = null; try { if (logMethod != null && (logMethod.loglevel().equals(LOGLEVEL.ALL) || logMethod.loglevel().equals(LOGLEVEL.OPERATION)) && (logMethod.logpos().equals(LOGPOS.BEFORE) || logMethod.logpos().equals(LOGPOS.ALL))) { doLog(logMethod, jp); } ret = jp.proceed(); if (logMethod != null && (logMethod.loglevel().equals(LOGLEVEL.ALL) || logMethod.loglevel().equals(LOGLEVEL.OPERATION)) && (logMethod.logpos().equals(LOGPOS.AFTER) || logMethod.logpos().equals(LOGPOS.ALL))) { doLog(logMethod, jp); } } catch (Throwable e) { e.printStackTrace(); throw e; } return ret; }
/** * 发生异常的时候,记录异常日志【记录范围:已经注册过的动作中的BusinessException】 * * @param jp * @param ex * @throws Exception * @author 朱启亮 * @date 2008-1-24 */ public void saveException(JoinPoint jp, Exception ex) throws Exception { if (ex instanceof BusinessException) { LogMethod logMethod = LogMethodText(jp); if (logMethod != null && (logMethod.loglevel().equals(LOGLEVEL.ALL) || logMethod.loglevel().equals(LOGLEVEL.EXCEPTION))) { String logText = logMethod.name(); String exceptionStr = exceptionToString(ex); String classStr = jp.getTarget().getClass().getName(); String methodStr = classStr + "." + jp.getSignature().getName(); logText += "时发生异常(" + methodStr + ") 具体信息:" + exceptionStr; saveLog(jp, logText, classStr, ex); } } }