I have a Spring Boot app (version 2.1.3.RELEASE) using Spring Cloud Sleuth and I would like to log the value of a baggage in the current Span Context. I am using Logback.
My logger has this logback configuration:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%date{ISO8601} %highlight(%-5level) %magenta(%thread) %cyan(%logger) %message %X{X-B3-TraceId} %X{X-B3-SpanId} %X{foo}%n
</pattern>
</encoder>
</appender>
<root level="info">
<appender-ref ref="STDOUT" />
</root>
</configuration>
In my Controller, I am trying to set a baggage on the current Span Context:
Span currentSpan = this.tracer.currentSpan();
ExtraFieldPropagation.set(currentSpan.context(), "foo", "bar");
In my application.properties, I have set the following properties:
spring.sleuth.propagation-keys=foo
# Set the value of the foo baggage into MDC:
spring.sleuth.log.slf4j.whitelisted-mdc-keys=foo
But I am not able to log the value of foo (with %X{foo}
).
The result is an empty string for foo:
My message e575e59578b92ace e575e59578b92ace