Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Aspect
- @Configuration
- public class JpaInterceptor {
- private static Logger logger = LoggerFactory.getLogger(JpaInterceptor.class);
- private ThreadLocal<SimpleDateFormat> sdf = new ThreadLocal<SimpleDateFormat>() {
- @Override
- protected SimpleDateFormat initialValue() {
- return new SimpleDateFormat("[yyyy-mm-dd hh:mm:ss:SSS]");
- }
- };
- @Pointcut("execution(public !void org.springframework.data.repository.Repository+.*(..))")
- public void jpaHandler() {
- }
- @Around("jpaHandler()")
- public Object logMethodCall(ProceedingJoinPoint jp) throws Throwable {
- String methodName = jp.getSignature().getName();
- logger.info(sdf.get().format(new Date()) + methodName);
- return jp.proceed();
- }
- }
Add Comment
Please, Sign In to add comment