0
我想實現AspectJ日誌記錄模塊來更好地分析它。我的應用程序已經在使用log4J框架。
如果我在一個單獨的應用程序中運行AspectJ類,它工作正常,但它在我將它與應用程序集成時不起作用。在這裏我做了什麼
的applicationContext.xmlAspectJ日誌與Log4j
<aop:aspectj-autoproxy/>
<bean id="logAspectj" class="com.test.aspect.LoggingAspect"/>
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;
}
}
注:這裏TestMarshaller不通過Spring暴露。
Log4j是否有一些特定的AspectJ設置?