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设置?