SpringCloud Eureka注册中心日志输出问题:Running the evict task with compensationTime 0ms
启动Eureka注册中心后,控制台一直输出 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms 这段日志,间隔时间与你的配置有关。强迫症看着很烦,那么在开发过程中如何关闭这条日志输出呢?
首先我们来看这段日志是从哪来输出的:
在AbstractInstanceRegistry类中有一个内部类EvictionTask
class EvictionTask extends TimerTask { private final AtomicLong lastExecutionNanosRef = new AtomicLong(0L); EvictionTask() { } public void run() { try { long compensationTimeMs = this.getCompensationTimeMs(); AbstractInstanceRegistry.logger.info("Running the evict task with compensationTime {}ms", compensationTimeMs); AbstractInstanceRegistry.this.evict(compensationTimeMs); } catch (Throwable var3) { AbstractInstanceRegistry.logger.error("Could not run the evict task", var3); } }
找到日志输出位置后,我们可以通过配置日志输出级别来过滤此条日志的输出,具体方法如下:
在Springboot的配置文件(application.yml,当然在log4j的配置中修改也是可以的)中添加配置:
logging: level: com.netflix: warn
原文:
https://blog.csdn.net/weixin_41633157/article/details/101108073