我正在與春天3.0.6。我的應用程序有很多地方添加日誌記錄(slf4j)。假設我需要在每個嚴重錯誤上添加一些函數 - 對我來說,每次調用錯誤級別日誌記錄會更好,並且可能會在發送後支持異常消息或者像這樣的消息 - 而不是手動將代碼添加到應用程序中的所有位置。春天aspectj切入點與slf4j
我已經創建了以下類:
@Aspect
public class LoggingWrapper {
@Pointcut("execution (* org.slf4j.Logger.error(..))")
public void logError() {
}
@AfterReturning("logError()")
public void afterError() {
//System.out.println("LOGERROR ASPECT AFTER");
//send email...
}
}
在Spring配置:
<aop:aspectj-autoproxy />
<bean id="loggingWrapper" class="com.app.services.LoggingWrapper"/>
方面是我的班運作良好,但對於org.slf4j.Logger - 什麼都沒有發生
+1工作得非常好。 – Ritesh 2014-05-21 20:49:25