I have some logback configuration:
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<outputPatternAsHeader>true</outputPatternAsHeader>
<pattern>[%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
How can I add my own parameters in pattern? Something like:
<pattern>[%thread] %-5level %logger{35} %user.name %status - %msg%n</pattern>
Consider use of Logback Mapped Diagnostic Contexts MDC then put the parameter in MDC like this MDC.put( "userName", "George" );
.
To print it with patternLayout do <pattern>[%thread] %-5level %logger{35} %X{userName} %status - %msg%n</pattern>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With