@Aspect @Component @Order(100) public class LogAspect { static Logger logger = LoggerFactory.getLogger(LogAspect.class); @Pointcut("execution(* com.zebra.carcloud.trip.service.*.*.*(..))") public void executeService(){ } @Before("executeService()") public void logBefore(JoinPoint joinPoint) { if(ReqIdUtil.getReqId() == null) { ReqIdUtil.setReqId(ReqIdUtil.getReqIdForService()); } logger.info(new StringBuilder("****") .append(joinPoint.getTarget().getClass().getName()).append(" ==> ").append(joinPoint.getSignature().getName()).append(" 方法执行开始...****").toString()); logger.info(new StringBuilder("请求REQ_ID:").append(ReqIdUtil.getReqId()).append(",参数:").append(StringUtil.getJsonByObj(joinPoint.getArgs())).toString()); } @After("executeService()") public void logAfter(JoinPoint joinPoint) { logger.info(new StringBuilder("请求REQID:").append(ReqIdUtil.getReqId()).toString()); logger.info(new StringBuilder(joinPoint.getTarget().getClass().getName()) .append("****").append(joinPoint.getSignature().getName()).append(" 方法执行结束****").toString()); ReqIdUtil.removeReqId(); } }
spring AOC切片
猜你喜欢
转载自javakill.iteye.com/blog/2359707
今日推荐
周排行