From 626a4e320cbcc6fdaa4da5a17db265763c1ae75b Mon Sep 17 00:00:00 2001 From: wenc000 <450292408@qq.com> Date: Fri, 8 May 2020 19:33:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=B3=BB=E7=BB=9F=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=AE=B0=E5=BD=95=E5=BC=80=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cm/common/aspect/ApiLogAspect.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cloud-common-plugin/src/main/java/com/cm/common/aspect/ApiLogAspect.java b/cloud-common-plugin/src/main/java/com/cm/common/aspect/ApiLogAspect.java index 9a7b7e6..0503f12 100644 --- a/cloud-common-plugin/src/main/java/com/cm/common/aspect/ApiLogAspect.java +++ b/cloud-common-plugin/src/main/java/com/cm/common/aspect/ApiLogAspect.java @@ -16,6 +16,7 @@ import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.core.annotation.Order; import org.springframework.core.io.InputStreamSource; import org.springframework.stereotype.Component; @@ -39,6 +40,8 @@ public class ApiLogAspect { private SecurityComponent securityComponent; @Autowired private ISystemLoggerService systemLoggerService; + @Value("${logging.enable-syslog:false}") + private Boolean enableSyslog; /** * api切入点 @@ -49,6 +52,9 @@ public class ApiLogAspect { @Around("apiCutPoint()") public Object apiLogAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { + if (enableSyslog == null || !enableSyslog) { + return proceedingJoinPoint.proceed(); + } return logAroundForApi(proceedingJoinPoint); } @@ -61,6 +67,9 @@ public class ApiLogAspect { @Around("resourceCutPoint()") public Object resourcesLogAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { + if (enableSyslog == null || !enableSyslog) { + return proceedingJoinPoint.proceed(); + } return logAroundForResource(proceedingJoinPoint); } @@ -73,6 +82,9 @@ public class ApiLogAspect { @Around("appCutPoint()") public Object appLogAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { + if (enableSyslog == null || !enableSyslog) { + return proceedingJoinPoint.proceed(); + } return logAroundForApp(proceedingJoinPoint); } @@ -164,7 +176,7 @@ public class ApiLogAspect { systemLoggerVO.setStartTime(startTime); systemLoggerVO.setEndTime(endTime); systemLoggerVO.setUsedTime(usedTime); - systemLoggerVO.setResponseResult(result == null ? "null" : JSON.toJSONString(result)); + // systemLoggerVO.setResponseResult(result == null ? "null" : JSON.toJSONString(result)); Map params = WMapUtil.beanToMapObj(systemLoggerVO); params.put("systemLoggerId", UUIDUtil.getUUID()); params.put("gmtCreate", currentTime); @@ -203,7 +215,7 @@ public class ApiLogAspect { systemLoggerVO.setStartTime(startTime); systemLoggerVO.setEndTime(endTime); systemLoggerVO.setUsedTime(usedTime); - systemLoggerVO.setResponseResult(result == null ? "null" : JSON.toJSONString(result)); + // systemLoggerVO.setResponseResult(result == null ? "null" : JSON.toJSONString(result)); Map params = WMapUtil.beanToMapObj(systemLoggerVO); params.put("systemLoggerId", UUIDUtil.getUUID()); params.put("gmtCreate", currentTime);