With below AspectJ Local configurations, we can add auto logging for methods.
@Aspect
public class AspectLogging {
methodName(){}
}
@Pointcut("execution(public * *.*(..))"")
public void executionScope(){
}
For more detail regarding pointcut visit: https://docs.spring.io/spring-framework/docs/2.0.x/reference/aop.html
@Before("executionScope()")
public void beforeAnyMethod(JoinPoint joinPoint) {
AspectJMethodLoggers.beforeAnyMethod(joinPoint);
}
@After("executionScope()")
public void afterAnyMethod(JoinPoint joinPoint) {
AspectJMethodLoggers.afterAnyMethod(joinPoint);
}
Once the AspectJ implementation is done execute a simple test case then observe the loggers in the console.
Implementation Reference: https://github.com/znsio/teswiz/blob/main/src/test/java/com/znsio/teswiz/aspect/AspectLogging.java