import org.aspectj.lang.JoinPoint; import org.aspectj.lang.Signature; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public aspect LogAspect { declare precedence : LogAspect, *; private Log getLog(final Signature pSignature) { return LogFactory.getLog(pSignature.getDeclaringType()); } pointcut returnCalls() : !within(LogAspect) && //!within(container.Builder) && ( execution(* org.whatever..*(..)) || execution(* org.whatever..*()) ) && ( (execution(public static * *.*(..)) && !execution(public static void *.*(..))) || (execution(public static * *.*()) && !execution(public static void *.*())) || (execution(public * *.*(..)) && !execution(public void *.*(..))) || (execution(public * *.*()) && !execution(public void *.*())) ); pointcut voidCalls() : !within(LogAspect) && //!within(container.Builder) && ( execution(* org.whatever..*(..)) || execution(* org.whatever..*()) ) && ( execution(public static void *.*(..)) || execution(public static void *.*()) || execution(public void *.*(..)) || execution(public void *.*()) || execution(new(..)) || execution(new()) ); after() throwing(Throwable pThrowable) : voidCalls() || returnCalls() { } Object around() : voidCalls() { final Object result = proceed(); return result; } Object around() : returnCalls() { final Object result = proceed(); return proceed(); } }