import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class LoggingInterceptor implements MethodInterceptor { private static final Logger logger = LogManager.getLogger(LoggingInterceptor.class); public Object invoke(MethodInvocation invocation) throws Throwable { logger.info("Method " + invocation.getMethod().getName() + " is about to be invoked."); Object result = invocation.proceed(); logger.info("Method " + invocation.getMethod().getName() + " has been invoked."); return result; } }


上一篇:
下一篇:
切换中文