Saturday, March 21, 2020

Aspects to log enter and exit method

The idea is:

use @EnableAspectJAutoProxy in a @Configuration

create an annotation EntryExitLogger to mark the method(s) you want to be logged for entry/exit

have a @Component annotated with @Aspect and inside it you specify the aspects:

public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable{

That's all.

Detailed post on the topic

Doc of AspectJ here

Good Aspectj cookbock here