欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

基于Aspect的日志记录参数 博客分类: Java java 

程序员文章站 2024-03-24 08:41:52
...
import java.util.Arrays;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;

import com.auto.RestLogger;

@Service
@Aspect
public class LogParamAspect
{
    public static Logger logger = RestLogger.getLogger();

    @Before("execution(public * com.auto.common.rest..*.*Service.*(..))")
    public void paramCheck(JoinPoint joinPoint)
    {
        logger.trace("Request Method:[{}], Params: {}", joinPoint.getSignature().getDeclaringTypeName() + "."
                + joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs()));
    }
}
相关标签: java