0

Correlation ids were working fine in a Spring Boot 3.0.2 + Spring Cloud Gateway application with micrometer-tracing.

After upgrading to any of the following releases of Spring Boot they don't show up in the logs any more.

I tried using the updated micrometer tracing dependencies in the 3.0.2 and still worked so it must be something related to Spring Boot, not Micrometer.

Any ideas?

codependent
  • 23,193
  • 31
  • 166
  • 308
  • seems u did not specified in pattern, in new spring boot 3 version u have to put mannualy by adding logging pattern in application.properties. you can study this issue by this link https://github.com/spring-projects/spring-boot/issues/33280 – YWILLS Apr 12 '23 at 18:42
  • I'm having the same issue w/ Spring Boot v3.1.0. Just switching from Sleuth to Micrometer Tracing, I haven't gotten it to work. I have the pattern setup (via log4j2), the bridge dependency in the pom file. I'm sure what else is necessary. – Joseph Freeman Jun 06 '23 at 15:44

2 Answers2

1

Right now you need to add it manually, e.g.:

logging.pattern.level=%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]

See in our samples. We have an issue for that: https://github.com/spring-projects/spring-boot/issues/33280

Jonatan Ivanov
  • 4,895
  • 2
  • 15
  • 30
  • Sorry for the lack of context. That isn't the problem, the logging pattern was already configured: `logging.pattern.level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]"` – codependent Apr 14 '23 at 10:44
  • Could you please try out one of our samples: https://github.com/micrometer-metrics/micrometer-samples – Jonatan Ivanov Apr 14 '23 at 19:16
0

Had the same issue with spring boot 3. Removed sleuth dependency and added micrometer dependecy. Below are the sample codes:

    <dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-tracing-bridge-brave</artifactId>
        <version>1.1.1</version>
    </dependency>

Logback config:

   <appender class="ch.qos.logback.core.ConsoleAppender" name="stdout">
    <encoder>
         <pattern>
            %d{yyyy-MM-dd} | %d{HH:mm:ss.SSS} | %thread | %5p | %logger{25} | %12(ID: %8mdc{id}) | %X{traceId:-} | "%X{spanId:-}" | appName | %m%n 
        </pattern>
    </encoder>
</appender>
<appender class="ch.qos.logback.core.ConsoleAppender" name="jsonstdout">
    <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
        <providers>
            <timestamp>
                <timeZone>EST</timeZone>
                 <timestampPattern>yyyy-MM-dd'T'HH:mm:ss.SSS</timestampPattern>
            </timestamp>
                <pattern>
                <pattern>
                    {
                        "service" : "appName",
                        "level": "%p",
                        "thread": "%thread",
                        "trace": "%X{traceId:-}",
                        "span": "%X{spanId:-}",
                        "class": "%logger{40}",
                        "message": "%m"
                    }
                </pattern>
            </pattern>
            <stackTrace>
                <throwableConverter 
           class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
                    <maxDepthPerThrowable>30</maxDepthPerThrowable>
                    <maxLength>2048</maxLength>
                    <shortenedClassNameLength>20</shortenedClassNameLength>
                    <rootCauseFirst>true</rootCauseFirst>
                </throwableConverter>
            </stackTrace>
        </providers>
    </encoder>
</appender>
Kuppusamy
  • 65
  • 1
  • 6
  • Did the above work? I'm having the same issue, though I've using log4j2 and not logback but I'd imaged that shouldn't make a difference. – Joseph Freeman Jun 06 '23 at 15:37
  • Yes..this config works fine. Producing log as : {"@timestamp":"2023-06-08T10:31:45.407033486+08:00","service":"ABC","level":"DEBUG","thread":"http-nio-9001-exec-1","trace":"64813d910ef4631c20585d2ab6629027","span":"8f1acdff7e631282","class":"o.s.web.servlet.DispatcherServlet","message":"GET \"/ABC/actuator/prometheus\", parameters={}"} – Kuppusamy Jun 08 '23 at 02:31
  • Thanks for the update! Yeah I still can't get this to work. Though I'm using the latest version of spring boot v3.1.0, not sure if that makes a difference. I created a stackoverflow question here -> https://stackoverflow.com/questions/76409733/spring-boot-v3-1-0-webflux-micrometer-tracing-logging-trace-and-span-ids Can we continue the conversation there and let me know if I need to add more details. I appreciate the help! – Joseph Freeman Jun 08 '23 at 13:43