I have a spring boot app that's deployed in google cloud and I face a rather odd problem. The X-Cloud-Trace-Context is set by google (load balancer I suppose) but the traceId of the app level logs have a different traceId (different from the one I see in the response headers in postman).
So in this photo you can see the postman headers including the traceId ending in 54e11 (with o=1).
In this one you can that the request log entry has the traceId ending in 54e11 but the entry above (the one you can't see but it's the one from the app log) has a traceId ending in 992da (which is different from the one in the POST request log).
Why is it different between request log and app log ? Do I need to write a custom filter to extract the traceId from the headers (if found) and do something with it like put it in the MDC map ?
My pom has the following dependency :
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-logging</artifactId>
</dependency>
My appender configuration (logback-spring.xml) is pretty basic :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="projectId" value="${projectId:-${GOOGLE_CLOUD_PROJECT}}"/>
<appender name="CONSOLE_JSON" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.springframework.cloud.gcp.logging.StackdriverJsonLayout">
<projectId>${projectId}</projectId>
<includeException>true</includeException>
</layout>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE_JSON" />
</root>
</configuration>
Thanks in advance for your time.
I want to also add that I followed the upvoted solution from this post but I still have the same problem Spring Boot Logging and Google Cloud Platform Log Viewer