I am trying to inject AspectJ logging into a module to better analyze it. My application already uses the log4J framework.
If I run the AspectJ class in a separate application, it works fine, but it does not work when I integrate it with the application. Here is what i did
applicationContext.xml
<aop:aspectj-autoproxy/> <bean id="logAspectj" class="com.test.aspect.LoggingAspect"/>
Class LoggingAspect
@Component @Aspect public class LoggingAspect { private final Log log = LogFactory.getLog(this.getClass()); @Around("execution(public void com.db.TestMarshaller.saveDoc(..))") public Object logTimeMethod(ProceedingJoinPoint joinPoint) throws Throwable { StopWatch stopWatch = new StopWatch(); stopWatch.start(); Object retVal = joinPoint.proceed(); stopWatch.stop(); StringBuffer logMessage = new StringBuffer(); logMessage.append(joinPoint.getTarget().getClass().getName()); logMessage.append("."); log.info(logMessage.toString()); return retVal; } }
Note. Here TestMarshaller is not displayed through Spring.
Is there any specific AspectJ setup for Log4j?
Himanshu yadav
source share