admin管理员组文章数量:1391771
Initially I had such logging configuration in my spring boot 3.4 app:
logging:
...
pattern:
file: "%d [%thread] %-5level %-50logger{40}- %n"
console: "%d [%thread]%-5level %-50logger{40}- %n"
Then I've added tracing and trace/spanId was not added auomatically to my pattern so I've added:
pattern:
correlation: "[${spring.application.name:},%X{traceId:-},%X{spanId:-}]"
file: "%d [%thread]${logging.pattern.correlation} %-5level %-50logger{40} - %n"
console: "%d [%thread]${logging.pattern.correlation} %-5level %-50logger{40} %n"
Is there way to do it in a simpler way without explicit link to logging.pattern.correlation
?
is there smth like %thread
for corellation ?
Initially I had such logging configuration in my spring boot 3.4 app:
logging:
...
pattern:
file: "%d [%thread] %-5level %-50logger{40}- %n"
console: "%d [%thread]%-5level %-50logger{40}- %n"
Then I've added tracing and trace/spanId was not added auomatically to my pattern so I've added:
pattern:
correlation: "[${spring.application.name:},%X{traceId:-},%X{spanId:-}]"
file: "%d [%thread]${logging.pattern.correlation} %-5level %-50logger{40} - %n"
console: "%d [%thread]${logging.pattern.correlation} %-5level %-50logger{40} %n"
Is there way to do it in a simpler way without explicit link to logging.pattern.correlation
?
is there smth like %thread
for corellation ?
1 Answer
Reset to default 0The simplest way is doing nothing, this works out of the box and logs contain the correlation IDs.
Iy you override the pattern and you don't use logging.pattern.correlation
in it, it will bot be there (you are explicitly asking for not to be there).
See the docs: https://docs.spring.io/spring-boot/reference/actuator/tracing.html#actuator.micrometer-tracing.logging
本文标签: spring bootWhat is the simplest way to add corellationId to loggingpatternconsoleStack Overflow
版权声明:本文标题:spring boot - What is the simplest way to add corellationId to logging.pattern.console? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744765507a2624014.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论