/**
* Aop implementation of request log printing
*
* Created by wenqiangxia on 9:07 2017/10/27
*/
@Component
@Aspect
public class RequestLog {
public static final Logger LOG = LoggerFactory.getLogger(RequestLog.class);
/**
* Define a pointcut
*/
// @Pointcut("execution(* com.wqxia.*.*(..))")
@Pointcut("@annotation(com.wqxia.common.log.annotation.SystemLog)")
public void controllerLog() {}
/**
* Print Log before controller
* @param joinPoint
*/
@Before("controllerLog()")
public void before(JoinPoint joinPoint) throws Exception {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
LOG.info("请求IP:{}", request.getRemoteAddr());
LOG.info("请求路径:{}", request.getRequestURL());
LOG.info("请求方式:{}", requ
springAOP拦截并打印controller层请求日志---注解方式实现
最新推荐文章于 2023-04-03 15:46:36 发布