I've been seeing weird square brackets and can't find and info on what there might be, logs looking like that:
--2022-08-23 08:47:44.882 INFO [,,,] 30446 --- [)-192.168.0.165] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
--2022-08-23 08:47:44.882 INFO [,,,] 30446 --- [)-192.168.0.165] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
--2022-08-23 08:47:44.922 INFO [,,,] 30446 --- [)-192.168.0.165] o.s.web.servlet.DispatcherServlet : Completed initialization in 40 ms
as you can see there are brackets with commas after log level, at some point info in the brackets change like this:
DEBUG [,080578da-b973-450b-9cae-2c5900ab56fe,080578da-b973-450b-9cae-2c5900ab56fe,]
can't really find what that could be, i'am using default spring boot logging pattern,
could it be wrongfully used MDC without redeclaring the logging pattern?
if it is MDC problem then why any value in the brackets look like this: 080578da-b973-450b-9cae-2c5900ab56fe
The logger I'm using is Slf4j
CodePudding user response:
This could happen if you use Spring Cloud Sleuth. Spring Cloud Sleuth is a framework that adds the following to your logs:
- The application name (from the
spring.application.name
property) - A trace ID (a unique ID for each user-initiated request)
- A span ID (a unique ID for a unit of work)
These IDs can be used to correlate log messages in a distributed system (eg. microservices), because these IDs will be passed from microservice to microservice. In the documentation you can find an example of what this looks like.
In your case, you're not using these properties, which is why they're empty. The trace ID is automatically generated upon each request, which is why you sometimes see [,,]
and [,XXX,]
.
If you're not interested in these trace/span IDs, you can remove the spring-cloud-sleuth
or spring-cloud-starter-sleuth
library.