Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package com.example.demo;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class MyAspect {
private static final Logger LOG = LoggerFactory.getLogger(MyAspect.class);
@Pointcut("within(com.example.demo..*)")
private void everythingInMyApplication() {}
@Before("com.example.demo.MyAspect.everythingInMyApplication()")
public void logMethodName(JoinPoint joinPoint) {
LOG.info("Called {}", joinPoint.getSignature().getName());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment