zoukankan      html  css  js  c++  java
  • Java 使用AOP实现打印日志

    @Aspect
    @Component
    @Slf4j
    public class ControllerLogAspect {
        /**
         * 对所有的接口 添加日志 日志信息有 请求地址 被请求地址 请求参数
         *
         * @param joinPoint
         */
        @Before("@within(org.springframework.stereotype.Controller) || @within(org.springframework.web.bind.annotation.RestController)")
        public void restLogAccess(JoinPoint joinPoint) {
            ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
            String url = requestAttributes.getRequest().getRequestURI();
            String remoteAddr = requestAttributes.getRequest().getRemoteAddr();
            log.info("[WEB] remoteAddr: {},  URL: {}, args: {}", remoteAddr, url, joinPoint.getArgs());
        }
    
    }
  • 相关阅读:
    js原型杂谈
    arguments.callee.caller
    $resource
    sql的四种匹配模式
    AMD规范
    module.ngdoc
    angularjs杂谈
    浏览器前缀
    css21规范学习
    <meta>标签
  • 原文地址:https://www.cnblogs.com/zhanzhuang/p/12881017.html
Copyright © 2011-2022 走看看