4

I am not able to log the private methods using spring aop performance logging. Below is the configuration I am using below configuration

<aop:config proxy-target-class="true">
        <aop:pointcut id="allServiceMethods" expression="execution(* com.mycom.app.abc..*.*(..))"/>
        <aop:advisor pointcut-ref="allServiceMethods" advice-ref="performanceMonitor" order="2"/>
    </aop:config>

I am having cglib jar on my class path.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
Rajeev Akotkar
  • 1,377
  • 4
  • 26
  • 46
  • 1
    I am having some nested private method calls and want to log them as well – Rajeev Akotkar Feb 09 '16 at 19:13
  • I am afraid for nested calls it is a similar problem. The aspect only works when the method is call from outside, I guess because when called internally in the bean the AOP proxy is not used. – Benjamín Valero Jan 15 '21 at 11:06

1 Answers1

11

You have to use compile time weaving instead of the proxy usage for Spring AOP.

From Spring AOP - Supported Pointcut Designators

Due to the proxy-based nature of Spring’s AOP framework, protected methods are by definition not intercepted, neither for JDK proxies (where this isn’t applicable) nor for CGLIB proxies (where this is technically possible but not recommendable for AOP purposes). As a consequence, any given pointcut will be matched against public methods only!

If your interception needs include protected/private methods or even constructors, consider the use of Spring-driven native AspectJ weaving instead of Spring’s proxy-based AOP framework. This constitutes a different mode of AOP usage with different characteristics, so be sure to make yourself familiar with weaving first before making a decision.

Community
  • 1
  • 1
Peter
  • 783
  • 4
  • 14