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);