I'm trying to implement performance logging based off of this post: http://www.baeldung.com/spring-performance-logging. I'd like to log each controller endpoint and every database request. If you would like to see the full project, you can find it here. When I hit the endpoints nothing is logged. Placing a breakpoint within the interceptor class it doesn't stop either. I've already set my logging for the packages to the trace level. What am I missing? I believe it's something to with the @PointCut but after looking at the docs I believe I have it correct.
Interceptor
public class PerformanceMonitorInterceptor extends AbstractMonitoringInterceptor { @Override protected Object invokeUnderTrace(MethodInvocation methodInvocation, Log log) throws Throwable { String name = createInvocationTraceName(methodInvocation); StopWatch stopWatch = new StopWatch(); stopWatch.start(); log.trace(String.format("Method %s execution start at %s", name, LocalDateTime.now())); try { return methodInvocation.proceed(); } finally { stopWatch.stop(); log.trace(String.format("Method %s execution took %dms (%s)", name, stopWatch.getTotalTimeMillis(), DurationFormatUtils .formatDurationWords(stopWatch.getTotalTimeMillis(), true, true))); } } } Configuration
@Configuration @EnableAspectJAutoProxy @Aspect public class ContactControllerPerfLogConfig { @Bean public PerformanceMonitorInterceptor performanceMonitorInterceptor() { return new PerformanceMonitorInterceptor(); } // Any public method on the ContactController @Pointcut("execution(public * org.example.phonebookexample.app.contact.ContactController.*(..))") public void contactControllerMonitor() { } @Bean public Advisor contactControllerMonitorAdvisor( PerformanceMonitorInterceptor performanceMonitorInterceptor) { AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut(); pointcut.setExpression("org.example.phonebookexample.app.contact.ContactControllerPerfLogConfig.contactControllerMonitor()"); return new DefaultPointcutAdvisor(pointcut, performanceMonitorInterceptor); } }
application.properties?logging.level= trace?