Closed
Listed in
Description
Right now, as documented users have to set this in their config to get span id and trace ids in logs:
logging.pattern.level=%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]
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.
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
[-]Improve span and trace id display in logs[/-][+]Make is easier to add span and trace id to logs[/+]mentallurg commentedon Nov 27, 2022
@mhalbritter : I agree that the current for using trace ID and span ID in the logging format is bad and should be improved.
But I don't agree that it should be added to the format automatically. It may help in some cases, but it can make logs worse readable in many other cases.
Besides, new features should not break the current behaviour whenever possible.
welsh commentedon Dec 5, 2022
@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.
[-]Make is easier to add span and trace id to logs[/-][+]Make it easier to add span and trace id to logs[/+]philwebb commentedon May 22, 2023
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.
[-]Make it easier to add span and trace id to logs[/-][+]Automatically log correlation IDs when Micrometer tracing is being used[/+]9 remaining items