简体   繁体   中英

Sleuth doesnt print spanId,traceId in spring boot application

When i create a fresh project from spring.io , it works fine. I am able to see the span id,traceId and project name in the logs. But when i try to implement the same with an existing project, with same version of spring boot and sleuth it doesnt work. There is no logging pattern present in the application, its the default one provided by spring. Logging level is set to INFO on application package level, and also on logging.level.org.springframework.web=INFO.

So if you emit a log entry in your controller (eg: LOGGER.info("Hello"); ), you can see the event itself but without the tracing data.

This is usually caused by:

  • Overriding the log pattern ( logging.pattern.level )
  • Not using the right logging library (eg: Spring configures logback but somehow you use something else)
  • Using the wrong version (please never define versions for your Spring dependencies, always use the BOM for Boot and for Cloud)

Since as you said it works with a generated project, the issue must be in your application, try to remove things (dependencies, code) from it and narrow the problem down till you find the issue.

You can also try to set logging.level.org.springframework.web.servlet.DispatcherServlet=DEBUG so that you will have events that should contain tracing information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM