diff --git a/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/interceptor/PlusWebInvokeTimeInterceptor.java b/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/interceptor/PlusWebInvokeTimeInterceptor.java index 3181d9fd..7a5d02ff 100644 --- a/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/interceptor/PlusWebInvokeTimeInterceptor.java +++ b/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/interceptor/PlusWebInvokeTimeInterceptor.java @@ -1,5 +1,6 @@ package cc.iotkit.common.web.interceptor; +import cc.iotkit.common.api.Request; import cc.iotkit.common.utils.JsonUtils; import cc.iotkit.common.utils.SpringUtils; import cc.iotkit.common.utils.StringUtils; @@ -9,6 +10,7 @@ import cn.hutool.core.map.MapUtil; import com.alibaba.ttl.TransmittableThreadLocal; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.time.StopWatch; +import org.slf4j.MDC; import org.springframework.http.MediaType; import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.ModelAndView; @@ -43,15 +45,17 @@ public class PlusWebInvokeTimeInterceptor implements HandlerInterceptor { if (request instanceof RepeatedlyRequestWrapper) { BufferedReader reader = request.getReader(); jsonParam = IoUtil.read(reader); + Request req = JsonUtils.parseObject(jsonParam,Request.class); + MDC.put("requestId",req.getRequestId()); } - log.debug("[PLUS]开始请求 => URL[{}],参数类型[json],参数:[{}]", url, jsonParam); + log.debug("开始请求 => URL[{}],参数类型[json],参数:[{}]", url, jsonParam); } else { Map parameterMap = request.getParameterMap(); if (MapUtil.isNotEmpty(parameterMap)) { String parameters = JsonUtils.toJsonString(parameterMap); - log.debug("[PLUS]开始请求 => URL[{}],参数类型[param],参数:[{}]", url, parameters); + log.debug("开始请求 => URL[{}],参数类型[param],参数:[{}]", url, parameters); } else { - log.debug("[PLUS]开始请求 => URL[{}],无参数", url); + log.debug("开始请求 => URL[{}],无参数", url); } } @@ -72,8 +76,9 @@ public class PlusWebInvokeTimeInterceptor implements HandlerInterceptor { if (!prodProfile.equals(SpringUtils.getActiveProfile())) { StopWatch stopWatch = invokeTimeTL.get(); stopWatch.stop(); - log.debug("[PLUS]结束请求 => URL[{}],耗时:[{}]毫秒", request.getMethod() + " " + request.getRequestURI(), stopWatch.getTime()); + log.debug("结束请求 => URL[{}],耗时:[{}]毫秒", request.getMethod() + " " + request.getRequestURI(), stopWatch.getTime()); invokeTimeTL.remove(); + MDC.clear(); } } diff --git a/iot-starter/src/main/resources/logback-spring.xml b/iot-starter/src/main/resources/logback-spring.xml index 6322c4b5..d67285b4 100644 --- a/iot-starter/src/main/resources/logback-spring.xml +++ b/iot-starter/src/main/resources/logback-spring.xml @@ -7,7 +7,7 @@ + value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} [%X{requestId}] %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/> diff --git a/iot-test-tool/pom.xml b/iot-test-tool/pom.xml index 39ee8098..d06a387b 100755 --- a/iot-test-tool/pom.xml +++ b/iot-test-tool/pom.xml @@ -13,9 +13,8 @@ 提供用于测试的相关工具的模块 - - iot-test-mqtt + iot-virtual-device