Spring-cloud-sleuth: Automatic log pattern is not working when using with spring-boot-starter-log4j2

Created on 15 Feb 2016  路  7Comments  路  Source: spring-cloud/spring-cloud-sleuth

Hi,
I am using spring Cloud with spring-boot-starter-log4j2 and looks like the automatic pattern that includes app name, span id and trace id is not set as the docs are saying.

documentation

Most helpful comment

I got it working by simply adding log pattern and log4j2 dependancy.
Log4j2:
https://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html#howto-configure-log4j-for-logging
Pattern in application.properties:
logging.pattern.console=[%X{X-B3-TraceId},%X{X-B3-SpanId},%X{X-B3-ParentSpanId},%X{X-Span-Export}]

All 7 comments

It's a logback only feature I think (from Spring Boot, so nothing we can fix here anyway).

Maybe adding to the documentation will save others time to understand it. I finally found the comment in the source code and figured it out. Thanks anyway

Hi ezraroi,

How did you figure out to this problem with log4j2 ?

+1, how to make it working with log4j2?

I got it working by simply adding log pattern and log4j2 dependancy.
Log4j2:
https://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html#howto-configure-log4j-for-logging
Pattern in application.properties:
logging.pattern.console=[%X{X-B3-TraceId},%X{X-B3-SpanId},%X{X-B3-ParentSpanId},%X{X-Span-Export}]

Did anyone actually test this solution? From the boot docs they state that logging.pattern.console is logback specific...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oburgosm picture oburgosm  路  4Comments

andcuevas picture andcuevas  路  5Comments

marcingrzejszczak picture marcingrzejszczak  路  8Comments

gerasimovv88 picture gerasimovv88  路  7Comments

cosyman picture cosyman  路  6Comments