diff --git a/src/main/java/cn/axzo/pokonyan/filter/RequestLogHandlerInterceptor.java b/src/main/java/cn/axzo/pokonyan/filter/RequestLogHandlerInterceptor.java index b77f557..f352640 100644 --- a/src/main/java/cn/axzo/pokonyan/filter/RequestLogHandlerInterceptor.java +++ b/src/main/java/cn/axzo/pokonyan/filter/RequestLogHandlerInterceptor.java @@ -72,9 +72,13 @@ public class RequestLogHandlerInterceptor implements HandlerInterceptor, WebMvcC boolean isJson = JSONUtil.isTypeJSON(body); boolean shortLength = body.length() < 4000; if (shortLength) { - body = isJson ? JSONUtil.toJsonStr(JSONUtil.isTypeJSONObject(body) ? JSON.parseObject(body) : JSON.parseArray(body)) : body; - log.info("[requestUrl:{}][method:{}][param:{}][body:{}]", requestUrl, method, - JSON.toJSONString(request.getParameterMap()), body); + try { + body = isJson ? JSONUtil.toJsonStr(JSONUtil.isTypeJSONObject(body) ? JSON.parseObject(body) : JSON.parseArray(body)) : body; + log.info("[requestUrl:{}][method:{}][param:{}][body:{}]", requestUrl, method, + JSON.toJSONString(request.getParameterMap()), body); + } catch (Exception exception) { + log.warn("json 转化失败[requestUrl:{},body:{}]", requestUrl, body, exception); + } return; } else { log.warn("request body too long, ignore print"); @@ -83,6 +87,8 @@ public class RequestLogHandlerInterceptor implements HandlerInterceptor, WebMvcC } catch (IOException ioException) { log.warn("打印参数失败[requestUrl:{}]", requestUrl, ioException); + } catch (Exception exception) { + log.warn("打印参数失败[requestUrl:{}]", requestUrl, exception); } return;