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