Created
October 9, 2017 19:23
-
-
Save jakubhalun/164e695a1ccc65590da00c819b5a7a34 to your computer and use it in GitHub Desktop.
Logging interceptor as Advice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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