Esempio n. 1
0
 /**
  * 发生异常的时候,记录异常日志【记录范围:已经注册过的动作中的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);
     }
   }
 }
Esempio n. 2
0
  /**
   * 创建并保存日志对象
   *
   * @param logMethod
   * @param jp
   */
  private void doLog(LogMethod logMethod, ProceedingJoinPoint jp) {
    String logText = logMethod.name();
    String classStr = jp.getTarget().getClass().getName();

    Object obj = jp.getThis();
    if (obj instanceof AbstractAction) {
      AbstractAction action = (AbstractAction) obj;
      HttpServletRequest request = action.getRequest();
      logText += "\r\n请求:" + request.getRequestURI() + "\r\n";
      Enumeration params = request.getParameterNames();
      while (params.hasMoreElements()) {
        String param = (String) params.nextElement();
        String value = request.getParameter(param);
        logText += ("参数->" + param + ":" + value + "\r\n");
      }
    }
    saveLog(jp, logText, classStr);
  }