没有PerformanceMonitor截取程序的日志记录 [英] no logging for PerformanceMonitorInterceptor

查看:18
本文介绍了没有PerformanceMonitor截取程序的日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为PerformanceMonitorInterceptor

准备了这个简单的Bean
@Configuration
@EnableAspectJAutoProxy
@Aspect
public class PerfMetricsConfiguration {
    /**
     * Monitoring pointcut.
     */
    @Pointcut("execution(* com.lapots.breed.judge.repository.*Repository.*(..))")
    public void monitor() {
    }

    /**
     * Creates instance of performance monitor interceptor.
     * @return performance monitor interceptor
     */
    @Bean
    public PerformanceMonitorInterceptor performanceMonitorInterceptor() {
        return new PerformanceMonitorInterceptor(true);
    }

    /**
     * Creates instance of performance monitor advisor.
     * @return performance monitor advisor
     */
    @Bean
    public Advisor performanceMonitorAdvisor() {
        AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
        pointcut.setExpression("com.lapots.breed.judge.repository.PerfMetricsConfiguration.monitor()");
        return new DefaultPointcutAdvisor(pointcut, performanceMonitorInterceptor());
    }
}

它应该跟踪名称以Repository结尾的接口中的任何方法调用。 我在application.properties

中设置了日志级别
logging.level.org.springframework.aop.interceptor.PerformanceMonitorInterceptor=TRACE

但在执行期间,它不会在控制台中写入任何内容。有什么问题?

推荐答案

我也遇到过类似的问题,将useDynamicLogger改为FALSE后,问题得到修复。

@Bean
public PerformanceMonitorInterceptor performanceMonitorInterceptor() {
  return new PerformanceMonitorInterceptor(false);
}

这篇关于没有PerformanceMonitor截取程序的日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆