I am trying to implement AspectJ logging to module to analyze it better. My application is already using log4J framework.
If I run AspectJ class in a separate application it works fine but it doesn't work when I integrate it with application. Here what I have done
applicationContext.xml
<aop:aspectj-autoproxy/>
<bean id="logAspectj" class="com.test.aspect.LoggingAspect"/>
LoggingAspect class
@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 exposed via Spring.
Is there some specific AspectJ setting for Log4j?