Skip to content

Instantly share code, notes, and snippets.

@NutterzUK
Created October 27, 2020 19:36
Show Gist options
  • Save NutterzUK/8c908e8d64b9410f055b5b76799c26b1 to your computer and use it in GitHub Desktop.
Save NutterzUK/8c908e8d64b9410f055b5b76799c26b1 to your computer and use it in GitHub Desktop.
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