package com.mindskip.xzs.aop; import com.mindskip.xzs.configuration.spring.exception.ExceptionHandle; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; @Aspect @Component public class InterfaceLogHandler { private final static Logger logger = LoggerFactory.getLogger(InterfaceLogHandler.class); @Pointcut("execution(* com.mindskip.xzs.controller..*.*(..))") public void pointcut(){}; @Before("pointcut()") public void log(JoinPoint joinPoint){ ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletRequest request = attributes.getRequest(); logger.info("访问接口:{}",request.getRequestURI()); } }