首页 > 编程语言 >atools -> aspect -> LogAspect

atools -> aspect -> LogAspect

时间:2022-08-30 09:37:12浏览次数:63  
标签:log atools LogAspect springframework aspect org import

atools -> log -> aspect -> LogAspect 文件

package com.example.demo.atools.log.aspect;

import com.alibaba.fastjson.JSON;
import com.example.demo.atools.log.filter.LogFilter;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
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.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @Create: IntelliJ IDEA.
 * @Author: subtlman_ljx
 * @Date: 2020/09/09/9:22
 * @Description: 打印接口入参信息
 */
@Aspect
@Component
public class LogAspect {
    Logger logger = LoggerFactory.getLogger(LogAspect.class);

    /**
     * pom文件引入:
     *         <dependency>
     *             <groupId>org.springframework.boot</groupId>
     *             <artifactId>spring-boot-starter-aop</artifactId>
     *         </dependency>
     * 使用方式:
     * 在所需打印的接口方法上添加 @Log
     */

    /**
     *  层切点
     */
    @Pointcut("@annotation(log)")
    public void controllerAspect(Log log) {
    }

    @After("controllerAspect(log)")
    public void after(JoinPoint pjp, Log log)  {
        //获取所有参数包括body和Parameter TODO
        logger.info("Request Args   : {}", JSON.toJSONString(pjp.getArgs()));
    }
}

 

标签:log,atools,LogAspect,springframework,aspect,org,import
From: https://www.cnblogs.com/subtlman/p/16638138.html

相关文章

  • atools -> log -> interceptor -> InterceptorConfig
    atools->log->interceptor->InterceptorConfig 文件packagecom.example.demo.atools.log.interceptor;importorg.springframework.context.annotation.Config......
  • atools -> log -> interceptor -> MyInterceptor
    atools->log->interceptor->MyInterceptor 文件packagecom.example.demo.atools.log.interceptor;importorg.slf4j.Logger;importorg.slf4j.LoggerFactory;......
  • atools -> readme.txt
    atools->readme.txt 文件atools生命历程***2020/09/09***1、工具包处于测试阶段2、测试出现的问题:swagger不能正常显示、入参的参数body不能获取到3、计划引入切......
  • atools -> resp -> DomainException
    DomainException类文件packagecom.example.demo.atools.resp;/***@Create:IntelliJIDEA.*@Author:subtlman_ljx*@Date:2020/09/09/9:22*@Descriptio......
  • atools -> resp -> MyHandlerExceptionResolver
    MyHandlerExceptionResolver类文件packagecom.example.demo.atools.resp;importorg.springframework.web.bind.annotation.ExceptionHandler;importorg.springfram......
  • atools -> resp -> ServiceResp
    ServiceResp类文件packagecom.example.demo.atools.resp;/***@Create:IntelliJIDEA.*@Author:subtlman_ljx*@Date:2020/09/09/9:22*@Description:......
  • atools -> config -> AutoBean
    AutoBean类文件packagecom.example.demo.atools.config;importorg.springframework.beans.BeansException;importorg.springframework.context.ApplicationContext......
  • atools -> config -> SwaggerConfig
    SwaggerConfig类文件packagecom.example.demo.atools.config;importorg.springframework.context.annotation.Bean;importorg.springframework.context.annotation......