Measure and log execution time of annotated methods in a Spring app using AspectJ Note: Spring AOP is a proxy-based and cannot capture calls to private methods or calls made within a class
- Add
TimingAspectConfig.java
andTimeIt.java
to project - Add
aspectjweaver
dependency topom.xml
<dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency>
- Add
@EnableAspectJAutoProxy
to configuration class - Add annotation
@TimeIt
over methods which are to be timed - Check
log4j
logs to see timings