在这种情况下如何避免双重记录?
@AfterThrowing(pointcut="execution(String greeting(..))",throwing="e")
public void itsAFoo1(JoinPoint joinPoint, RemoteException e) {
logger.error(joinPoint.getSignature().toLongString() + " exception here!");
}
@After("execution(String greeting(..))")
public void itsAFoo2(JoinPoint joinPoint, RemoteException e) {
logger.error(joinPoint.getSignature().toLongString());
}
我有两个日志:
[2012-08-07 17:02:01,585] [request1344351718430] [public java.lang.String componentC.Hello.greeting(java.lang.String) exception here!]
[2012-08-07 17:02:01,585] [request1344351718430] [public java.lang.String componentC.Hello.greeting(java.lang.String)]
但如果有异常,我需要收到一个,如果没有,我需要收到一个。
答案 0 :(得分:2)
将@After更改为@AfterReturning
@AfterReturning("execution(String greeting(..))")
public void itsAFoo2(JoinPoint joinPoint, RemoteException e) {
logger.error(joinPoint.getSignature().toLongString());
}