Commit d4877cb0 authored by 赵浩琳's avatar 赵浩琳

日志打印参数过滤不能序列化的参数

parent e14b6393
...@@ -3,6 +3,10 @@ package cn.quantgroup.xyqb.aspect.logcaller; ...@@ -3,6 +3,10 @@ package cn.quantgroup.xyqb.aspect.logcaller;
import cn.quantgroup.xyqb.util.IpUtil; import cn.quantgroup.xyqb.util.IpUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Stopwatch; import com.google.common.base.Stopwatch;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
...@@ -51,8 +55,10 @@ public class LogCallHttpAspect { ...@@ -51,8 +55,10 @@ public class LogCallHttpAspect {
long elapsed = stopwatch.stop().elapsed(TimeUnit.MILLISECONDS); long elapsed = stopwatch.stop().elapsed(TimeUnit.MILLISECONDS);
String resultStr = result == null ? "" : JSON.toJSONString(result); String resultStr = result == null ? "" : JSON.toJSONString(result);
resultStr = resultStr.length() < 500 ? resultStr : resultStr.substring(0, 500); resultStr = resultStr.length() < 500 ? resultStr : resultStr.substring(0, 500);
log.info("[httpRequestLog],url:[{}],duration:[{}],[耗时区间]{},remoteIP:[{}],exception:[{}],result:[{}]", List<Object> argList = Arrays.stream(args).filter(arg -> arg instanceof Serializable)
request.getRequestURL(), elapsed, slowlyTag(elapsed), remoteIP, hasException, resultStr); .collect(Collectors.toList());
log.info("[httpRequestLog],url:[{}],duration:[{}],[耗时区间]{},remoteIP:[{}],args:[{}],exception:[{}],result:[{}]",
request.getRequestURL(), elapsed, slowlyTag(elapsed), remoteIP, JSON.toJSONString(argList), hasException, resultStr);
} }
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment