【发布时间】:2022-01-13 09:41:58
【问题描述】:
我正在尝试了解SpringBoot在实施Hysterix Circuit Breaker之前和之后生成的日志
在 Hystrix 之前,日志看起来像,
17:31:35.977 [http-nio-8080-exec-2] [TransID:bcc8a9e9-41b7-47c8-9eb1-0f8becb42f68] INFO c.f.e.common.logging.MethodLogging - Entered Class: class com.org.myapp.service.MyService, Method: getData, Arguments: 123456
实施 Hystrix 后的日志如下所示,
17:21:23.197 [hystrix-MyController-1] [TransID:] INFO c.f.e.common.logging.MethodLogging - Entered Class: class com.org.myapp.service.MyService, Method: getData, Arguments: 123456
那么,http-nio-8080-exec-2 是如何被 hystrix-OrchestratorController-1 替换的,以及为什么在实施 Hystrix 时它没有显示我的 TransactionId。 Hystrix 是如何接管日志的?两者有什么区别?有什么办法可以恢复到我的旧日志格式?
我在 application.properties 中尝试了hystrix.command.default.requestLog.enabled=false,但没有运气。
主类
@SpringBootApplication
@EnableCircuitBreaker
class MyApp{
}
休息控制器
@GetMapping("...")
@HystrixCommand(commandKey="data")
public Object getData(){
}
application.properties
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=5000
【问题讨论】:
-
Hystrix 使用线程池来做超时,因此不同的线程。不确定应该在您的日志中提供什么 transid,但这可能存储在一些本地线程中并被检索,而不是使用 MDC。
标签: java spring spring-boot logging hystrix