I have a j2ee web application running on Spring framework. I want to implement logging using log4j and Spring’s AOP. I was trying to find for references but I only get references which does not use log4j.
I had exactly the same configuration as what was on the link you gave. I have declared too a bean which where I want to implement logging. The beans id is ExecuteBLogic so I put below *BLogic
<bean name="methodLoggingInterceptor" class="org.developers.blog.spring.aop.logging.MethodLoggingInterceptor"/>
<bean name="proxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>*BLogic</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>methodLoggingInterceptor</value>
</list>
</property>
</bean>
There are many examples that show how to log information using spring AOP. The fact that they are using
System.outorjava.util.loggingshould bother you – just replace these lines with log4j lines.So, ontop of the class:
and then instead of
System.out.println(..):