-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically log correlation IDs when Micrometer tracing is being used #33280
Comments
@mhalbritter : I agree that the current for using trace ID and span ID in the logging format is bad and should be improved. |
@mentallurg previous behaviour that I experienced was that adding:
Did add it automatically to the default logging, so it was a surprise that I needed to manually add it back in when migrating to Spring Boot 3. |
A few of us discussed this issue again today and we'd like to default to the following format if tracing is enabled: When a correlation ID is present we'll use traceId dash spanId as recommended by w3c:
If the correlation is missing, we'll pad with spaces:
If one part of the correlation ID is missing, we'll pad with spaces and include the dash. This is considered a bug and we want the logs to look strange:
We think showing the application name in the logs is a useful feature outside of correlation IDs. We'll open a new issue to support it and enable it by default when correlation IDs are shown. We also discussed that it's important that slueth style correlation IDs can be used if the user wishes to do so. |
Docs related to gh-33280 (log correlation) and gh-35593 (application name in each log line) need some polishing: - Fix project names - Show how to avoid having the application name duplicated in logs - Call out that a trailing space is needed in the correlation pattern Closes gh-36035 See gh-33280 See gh-35593
Right now, as documented users have to set this in their config to get span id and trace ids in logs:
Besides that it abuses the logging level pattern, it is not a good developer experience.
I would prefer it to be auto-configured in the case a
Tracer
bean is available. Not sure if this is technically feasible.We should additionally introduce a
logging.pattern.correlation
property which can be used.The text was updated successfully, but these errors were encountered: