Don't create your proxies manually, use Spring AOP to create your Logging Proxy.
Create a simple Aspect:
@Aspect
public class LoggingAspect{
private static final Logger log = Logger.getLogger(LoggingAspect.class);
@Pointcut("execution(* *.*(..))")
public void methodExecution(){
}
@Before("methodExecution()")
public void logBeforeMethod(final JoinPoint joinPoint){
log.trace("Entering method " + joinPoint.getSignature() + " with args "
+ Arrays.toString(joinPoint.getArgs()));
}
}
Now wire the aspect in Spring:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean class="aspects.LoggingAspect" />
<aop:aspectj-autoproxy />
</beans>
Now all your Spring Beans will be proxies and all of their method executions (at leaast those backed by an interface) will be logged.
BTW: Tracing Aspects are covered in
the free Chapter 10 of AspectJ
in Action by Ramnivas Laddad