请求日志添加 traceId
This commit is contained in:
@@ -11,10 +11,13 @@ import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 方法调用统一切面处理
|
||||
@@ -59,7 +62,13 @@ public class ControllerAspect {
|
||||
String requestUrl = request.getRequestURL().toString();
|
||||
String requestIp = ServletUtil.getClientIP(request);
|
||||
long useTime = end - start;
|
||||
|
||||
Map<String, String> contextMap = MDC.getCopyOfContextMap();
|
||||
ThreadUtil.execAsync(() -> {
|
||||
if (contextMap != null) {
|
||||
MDC.setContextMap(contextMap);
|
||||
}
|
||||
|
||||
//请求的参数
|
||||
String resultJson = JSONObject.toJSONString(result);
|
||||
if (StrUtil.isNotBlank(resultJson) && resultJson.length() > 200) {
|
||||
@@ -82,6 +91,8 @@ public class ControllerAspect {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Request 为空" + e.getMessage());
|
||||
} finally {
|
||||
MDC.clear();
|
||||
}
|
||||
});
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user