• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sleuth is overriding logging.pattern.level configured in application.properties for logging pattern.

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have started integrating Spring cloud Sleuth into our project to generate automatic trace-id and span-id. The project is built on Spring boot v2.5.6. The steps I did are:

1. Added spring-cloud version and spring-cloud-starter sleuth dependency in the pom.xml



2. As I want to modify the default format of logging into our required format, as per documentation I added below property in the application.properties

     

3. I have below logback files in the classpath:

logback.xml



logback-custom-logging.xml



NOTE: In the above CONSOLE_LOG_PATTERN property, I have modified it to show traceid and spanid after PID and not after LOG_LEVEL_PATTERN as sleuth does by default by overriding logging.pattern.level to add spring app name, traceid and spanid. Please check below for the current and expected logger formats.

Result: After all this change still Sleuth is adding trace id and span id by overriding the log level and also I am getting trace and span id after PID.

How can I modify so that Sleuth does not add trace id and span id as in default format in the logs?

Current log:


Expected Log:
 
Bartender
Posts: 2436
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about using this:
<logger name="org.springframework.boot.SpringApplication" level="info">
 <appender-ref ref="CONSOLE" />
</logger>
instead of
<root level="INFO">
       <appender-ref ref="CONSOLE"/>
     </root>

And you may need to specify a customized pattern in an appender.
 
Jagan Mohan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Himai Minh wrote:How about using this:
<logger name="org.springframework.boot.SpringApplication" level="info">
 <appender-ref ref="CONSOLE" />
</logger>
instead of
<root level="INFO">
       <appender-ref ref="CONSOLE"/>
     </root>

And you may need to specify a customized pattern in an appender.



I tried this approach. And strangely, after this the loggers were the default ones and not the ones with Traceid and Spanid  that sleuth generates. As per suggestion I created an appender for Console and I gave CONSOLE_LOG_PATTERN as the pattern value. But that did not work to achieve the result.
 
Let me tell you a story about a man named Jed. He made this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic