Merge branch 'master' into v4.1_dev
This commit is contained in:
@@ -53,9 +53,9 @@ public class LogInterceptor extends BaseService implements HandlerInterceptor {
|
|||||||
@Override
|
@Override
|
||||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
|
||||||
Object handler, Exception ex) throws Exception {
|
Object handler, Exception ex) throws Exception {
|
||||||
long beginTime = startTimeThreadLocal.get();// 得到线程绑定的局部变量(开始时间)
|
Long beginTime = startTimeThreadLocal.get();// 得到线程绑定的局部变量(开始时间)
|
||||||
long endTime = System.currentTimeMillis(); // 2、结束时间
|
long endTime = System.currentTimeMillis(); // 2、结束时间
|
||||||
long executeTime = endTime - beginTime; // 3、获取执行时间
|
long executeTime = beginTime == null ? 0 : endTime - beginTime; // 3、获取执行时间
|
||||||
startTimeThreadLocal.remove(); // 用完之后销毁线程变量数据
|
startTimeThreadLocal.remove(); // 用完之后销毁线程变量数据
|
||||||
|
|
||||||
// 保存日志
|
// 保存日志
|
||||||
|
|||||||
@@ -113,19 +113,19 @@ public class LogUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 异步保存日志
|
// 异步保存日志
|
||||||
logThreadPool.submit(new SaveLogTask(log, handler, request.getContextPath(), throwable));
|
logThreadPool.submit(new SaveLogThread(log, handler, request.getContextPath(), throwable));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 保存日志线程
|
* 保存日志线程
|
||||||
*/
|
*/
|
||||||
public static class SaveLogTask extends Thread{
|
public static class SaveLogThread extends Thread{
|
||||||
|
|
||||||
private Log log;
|
private Log log;
|
||||||
private Object handler;
|
private Object handler;
|
||||||
private String contextPath;
|
private String contextPath;
|
||||||
private Throwable throwable;
|
private Throwable throwable;
|
||||||
|
|
||||||
public SaveLogTask(Log log, Object handler, String contextPath, Throwable throwable){
|
public SaveLogThread(Log log, Object handler, String contextPath, Throwable throwable){
|
||||||
this.log = log;
|
this.log = log;
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
this.contextPath = contextPath;
|
this.contextPath = contextPath;
|
||||||
|
|||||||
Reference in New Issue
Block a user