From 3609c6ecf2463e34ebe40287aeb3a651c59b7060 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=86=AF=E5=87=AF?= <371894675@qq.com>
Date: Wed, 22 Nov 2023 11:07:00 +0800
Subject: [PATCH] 3.6.5
---
pom.xml | 2 +-
.../java/com/dragon/common/log/aspect/LogAspect.java | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 59eb25e..f2119c2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
3.6.4
- 3.6.4
+ 3.6.5
4.0.0
dragon-common-log
diff --git a/src/main/java/com/dragon/common/log/aspect/LogAspect.java b/src/main/java/com/dragon/common/log/aspect/LogAspect.java
index 698812e..9c41766 100644
--- a/src/main/java/com/dragon/common/log/aspect/LogAspect.java
+++ b/src/main/java/com/dragon/common/log/aspect/LogAspect.java
@@ -23,6 +23,9 @@ import org.springframework.core.NamedThreadLocal;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import org.springframework.validation.BindingResult;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
@@ -56,6 +59,12 @@ public class LogAspect {
*/
@Before(value = "@annotation(controllerLog)")
public void boBefore(JoinPoint joinPoint, Log controllerLog) {
+ ServletRequestAttributes attributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
+ HttpServletRequest request = attributes.getRequest();
+ log.info("========================================== Start ==========================================");
+ log.info("URL:{}",request.getRequestURL().toString());
+ log.info("method:{}",request.getMethod());
+ log.info("请求ip是:",request.getRemoteAddr());
TIME_THREADLOCAL.set(System.currentTimeMillis());
}
@@ -67,6 +76,8 @@ public class LogAspect {
@AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult")
public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult) {
handleLog(joinPoint, controllerLog, null, jsonResult);
+ // 接口结束后换行,方便分割查看
+ log.info("=========================================== End ===========================================");
}
/**