now for a particular log message for the %p sign i wil get either debug or error or warning. can anyone tel me how to get only the first three letters. eg. only WAR for Warning
In log4j 2.x, you can truncate from the end:
Truncation from the end is possible by appending a minus character right after the period. In that case, if the maximum field width is eight and the data item is ten characters long, then the last two characters of the data item are dropped.
Link: https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout
So in this case, %.-3p
should give WAR
instead of WARNING
.
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