Member-only story
Logging Correlation Id in Spring Boot 3.2.1
In this tutorial, We will learn How to log correlationId in each log statement.
As we know spring boot starts logging a correlation Id for each log relating to Http transaction. This behavior is ON by default as long as micrometer tracing is enabled.
What is Correlation Id ?
A Correlation ID is a unique identifier assigned to a request that allows tracking it through various components.
for example: k205991b-c613–4acd-97b8–59112b2b2ak0
Why Use Correlation IDs in Spring Boot?
Challenges: Because it is difficult to trace the requests in a distributed system without Correlation IDs.
Benefits: Easier to debugging and troubleshooting with Correlation IDs.
For Example : if multiple clients calling to same API then it will print all the logs mixed .
Then it is difficult to identify the sequence of request processed logs. Here below we can see the logs without implementation of correlationId when multiple clients calling API.