统一的异常类日志的打印
一、异常类日志打印AccessLogAspect
@Aspect
@Component
@Slf4j
public class AccessLogAspect {
@Autowired
CommonService commonService;
@Pointcut("@annotation(org.springframework.web.bind.annotation.RestController)" + "|| @within(org.springframework.web.bind.annotation.RestController)")
public void pointCut() {
}
@Around("pointCut()")
public Object around(ProceedingJoinPoint point) throws Throwable {
String requestUri = commonService.getRequest().getRequestURI();
if(log.isDebugEnabled()) {
log.debug("===start ==={}==============", requestUri);
}
Object[] args = point.getArgs();
if (args != null) {
if(log.isDebugEnabled()) {
log.debug("args: {}", JSONUtil.parseArray(args));
}
}
StopWatch stopWatch = new StopWatch();
stopWatch.start();
Object proceed = point.proceed();
stopWatch.stop();
if(log.isDebugEnabled()) {
log.debug("===end ==={} ===用时: {} ms===========\n", requestUri, stopWatch.getTotalTimeMillis());
}
return proceed;
}
}