Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In spring-boot, how to log MDC using application properties?

In my spring-boot project I am using Logback-"Mapped Diagnostic Context" MDC for logging diagnostic context.

MDC-data is not logged (to console or file) by default.

Is there a way for getting this MDC logs into the output-log, using only application properties?

like image 355
Markus Schulte Avatar asked Oct 27 '25 10:10

Markus Schulte


1 Answers

spring-boot provides some application properties for this. Have a look at common-application-properties.html.

You can find logging.pattern.level here. By setting

logging.pattern.level=%5p %mdc

data from MDC will be logged, too.

like image 142
Markus Schulte Avatar answered Oct 29 '25 00:10

Markus Schulte



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!