1

在这种情况下如何避免双重登录?

@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)]

但如果有异常,我需要收到一份,如果没有,我需要收到一份。

4

1 回答 1

2

将 @After 更改为 @AfterReturning

@AfterReturning("execution(String greeting(..))")
public void itsAFoo2(JoinPoint joinPoint, RemoteException e) {
    logger.error(joinPoint.getSignature().toLongString());
}
于 2012-08-08T07:22:54.850 回答