I use the following in my pattern(logback.xml) to replace 10 digit numbers in my log.
%replace(%msg){'\d{10}','**********'}
One problem with this approach is, it also matches first 10 digits of 11 digit number. Is there a way to match exactly 10 digits numbers.
Now the bigger problem is somehow I need to display the last two digits of this 10 digit number.
Use this:
%replace(%msg){'\b\d{10}\b','**********'}
\b
is a word boundary that matches a position where one side is a letter, and the other side is not a letter (for instance a space character, or the beginning of the string)
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