Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Logging interceptor as Advice
public class LoggingAdvice {
@Advice.OnMethodEnter
public static void intercept(@Advice.BoxedArguments Object[] allArguments,
@Advice.Origin Method method) {
Logger logger = LoggerFactory.getLogger(method.getDeclaringClass());
logger.info("Method {} of class {} called", method.getName(), method
.getDeclaringClass().getSimpleName());
for (Object argument : allArguments) {
logger.info("Method {}, parameter type {}, value={}",
method.getName(), argument.getClass().getSimpleName(),
argument.toString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.