log4j2 日志中未打印行李值
我正在使用 log4j2 和 sleuth 3.0.3
下面是我用来向 sleuth 添加行李的配置,
spring.sleuth.baggage.remote-fields=sessionId
spring.sleuth.baggage.correlation-fields=sessionId
我从如下所示的请求的控制器中设置了行李字段值。
BaggageField.getByName("sessionId").updateValue("value");
我可以使用 BaggageField.getByName("sessionId").getValue()
从其他点访问该值,并且正在传播到其他服务,但在当前服务中无法访问该值 添加了行李。
日志模式是
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%tid] [%t] [%X{sessionId},%X{traceId},%X{spanId}] %-5level %logger{36} - %msg%n"/>
每次我尝试打印它时,仅打印traceid和spanid,而会话id为空,如下所示。
[,e5bf8cd9dbf910dc,cb689f3c036b4260]
这里可能有什么问题
Iam using log4j2 and sleuth 3.0.3
Below is the confiugration I have used to add a baggage to sleuth
spring.sleuth.baggage.remote-fields=sessionId
spring.sleuth.baggage.correlation-fields=sessionId
I set the baggage field value from the controller of a request shown below.
BaggageField.getByName("sessionId").updateValue("value");
I am able to access the value from other points using BaggageField.getByName("sessionId").getValue()
and is being propagated to other services but it is not being acessible in the current service where
added the baggage.
the log pattern is
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%tid] [%t] [%X{sessionId},%X{traceId},%X{spanId}] %-5level %logger{36} - %msg%n"/>
Every time I try to print it only traceid and spanid is getting printed leaving session id empty as shown below.
[,e5bf8cd9dbf910dc,cb689f3c036b4260]
What could be the issue here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个答案已在
https://github.com/spring- cloud/spring-cloud-sleuth/issues/2120
自动刷新到勇敢的键完成了所需的技巧。
https://docs.spring.io/spring-cloud-sleuth/docs/3.1.1/reference/htmlsingle/spring-cloud-sleuth.html#features-baggage
This answer has been addressed at
https://github.com/spring-cloud/spring-cloud-sleuth/issues/2120
where automatically flush to brave keys did the needed trick.
https://docs.spring.io/spring-cloud-sleuth/docs/3.1.1/reference/htmlsingle/spring-cloud-sleuth.html#features-baggage