using AOP for adding logging to web layer
I am trying to add logging to trace the path a user took starting from structs action classes to the persistance layer via the service layer. The logging works for service and persistance layer, but does not work on the web layer.
I have several structs action classes in the abc.cde.action package and all have names ending in Action and they extend ActionSupport.
This is what I added to the application-context.xml
..
..
<import resource="spring/web-profiling.xml" />
..
..
This is in web-profiling.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!--
======================= Profiling Interceptor ====================================
-->
<!-- Before Advice Interceptor -->
<bean id="actionMethodBeforeInterceptor" class="abc.cde.myapp.aop.LoggingMethodBeforeInterc eptor" />
<bean name="webProfileAutoProxy"
class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>abc.cde.action.*Action</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>actionMethodBeforeInterceptor</value>
</list>
</property>
<property name="proxyTargetClass" value="true"></property>
</bean>
</beans>
This is LoggingMethodBeforeInterceptor
import java.lang.reflect.Method;
import org.apache.log4j.Logger;
import org.springframework.aop.MethodBeforeAdvice;
public class LoggingMethodBeforeInterceptor implements MethodBeforeAdvice
{
public void before(Method method, Object[] args, Object target) throws Throwable
{
Logger log = Logger.getLogger("myApp-file-web");
log.info("method="+method.getName() + " from " + target.getClass()+ " called");
}
}
I am not getting any errors, but not seeing anything in my logs.