2

I am using spring-cloud-starter-sleuth:3.0.1 and spring-cloud-sleuth-zipkin:3.0.1 to generate traceId and spanId in log file. I was able to get those in logs using 2.2.7.RELEASE version. I have tried using logback but not able to have with 3.0.1 version. As per 3.0.1 documentation, they have removed Legacy MDC entries but brave spanId & traceId are there.

Dependency hierarchy: Dependency_hierarchy

traceId & spanId are not generated in log:

Log

I have tried to see this request's tracing on zipkin and able to see it with traceid and spanid:

zipkin

Can anyone help me to get traceid and spanid in log file using logback/log4j?

maanijou
  • 1,067
  • 1
  • 14
  • 23
Ronak
  • 21
  • 3

1 Answers1

0

Sleuth does this for you by default in 3.x too: https://docs.spring.io/spring-cloud-sleuth/docs/current/reference/htmlsingle/#features-log-integration

You can break this functionality by misconfiguring your log pattern or logging.pattern.level or your classpath.

What I would suggest is going to https://start.spring.io, generate a new project using sleuth and web/webflux, write a single controller and check the logs (do not create any log config file, just leave everything on default).

Jonatan Ivanov
  • 4,895
  • 2
  • 15
  • 30