referring to quesition/answer in How to log MDC with Spring Sleuth?
I think this has/will change(d) with spring-cloud 2.0 as there is no SpanLogger
or Slf4jSpanLogger
anymore (or I don't find it)
Wouldn't it be nice if application properties spring.sleuth.baggage-keys
and spring.sleuth.propagation-keys
if set would also be put in MDC I think inside Slf4jCurrentTraceContext
(as this class is currently final
I cannot subclass it)
If not, how could I achieve this with spring-cloud 2.0 accordingly?
We don't want to put all entries in MDC (that really doesn't make a lot of sense). You can however either copy the Slf4jCurrentTraceContext
and extend it in the way you want to (and register it as a bean) or maybe create your own implementation of CurrentTraceContext
that would wrap the existing CurrentTraceContext
via a Bean Post Processor and perform additional logic. I guess the first option is more preferable.
来源:https://stackoverflow.com/questions/49581760/how-to-log-mdc-with-spring-sleuth-2-0