Thanks to my colleague for sharing this info on application monitoring using out of the box spring interceptors.
To put in place performance monitoring of service methods (methods annotated with @Service), do the following.
The interceptor class which will be used for this is org.springframework.aop.interceptor.PerformanceMonitorInterceptor.
In your spring application context configure the interceptor as below:-
1 2 3 4 5 |
<bean id="perfMonitor" class="org.springframework.aop.interceptor.PerformanceMonitorInterceptor"> <property name="logTargetClassInvocation" value="true"></property> </bean> |
1 2 3 4 5 6 7 |
<aop:config> <aop:pointcut expression="@target(org.springframework.stereotype.Service)" id="allServices"/> <aop:advisor pointcut-ref="allServices" advice-ref="perfMonitor"/> </aop:config> |
The logger has to be set at trace level for the logging to happen
1 2 3 4 5 |
<logger name="org.springframework.aop.interceptor"> <level value="trace" /> </logger> |
Page Visitors: 1809
The following two tabs change content below.

Tomcy John
Blogger & Author at javacodebook
He is an Enterprise Java Specialist holding a degree in Engineering (B-Tech) with over 10 years of experience in several industries. He's currently working as Principal Architect at Emirates Group IT since 2005. Prior to this he has worked with Oracle Corporation and Ernst & Young. His main specialization is on various web technologies and acts as chief mentor and Architect to facilitate incorporating Spring as Corporate Standard in the organization.

Latest posts by Tomcy John (see all)
- A Guide to Continuous Improvement for Architects - February 2, 2023
- Cloud-first Architecture Strategy - January 26, 2023
- Architecture Strategy and how to create One - January 24, 2023