Aspect 기반 로그 기록 매개 변수

880 단어 자바
더 읽 기

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()));
    }
}

좋은 웹페이지 즐겨찾기