I have web application based on Spring Boot and it uses logback for logging.
I also inherit some logback defaults from spring boot using:
<include resource="org/springframework/boot/logging/logback/base.xml"/>
I want to start logging tracing information, so I added:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
Sleuth adds tracing information to log lines, but I can't find any %X
or %mdc
in patterns: https://github.com/spring-projects/spring-boot/blob/2.3.x/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/defaults.xml
How does Sleuth add tracing information into log lines?
I use spring-cloud-starter-parent
Hoxton.SR9
parent which brings Spring Boot 2.3.5.RELEASE
and spring-cloud-starter-sleuth
2.2.6.RELEASE
org.springframework.cloud.sleuth.log.Slf4jScopeDecorator
adds information intoMDC
, but I don't understand how it is added into log line after log level. It is not mentioned in default log pattern defined in Boot. It's not only curiosity, I also have another project based on log4j2 where it doesn't work out of the box. The more ethical approach would be not to attack somebody based on unvalidated assumption. – Kiyohara