Search code examples
javalogginglogback

Invalid logback pattern


I was using this working pattern (logback.groovy):

{'((?:password(=|:|>))|(?:secret(=|:))|(?:salt(=|:)))','\$1*******\$3'}

to mask sensitive data. One day I needed to surround it with double quotes, like

was: password=smth became: "password"="smth"

So I turned regexp into this (just added \" before and after keywords, and also I've tried \\"):

{'(\"?(?:password\"?(=|:|>))|(?:secret\"?(=|:))|(?:salt\"?(=|:)))','\$1*******\$3'}

But I get this error on app startup:

Failed to parse pattern Unexpected character ('?' (code 63)): was expecting comma to separate Object entries

Can someone please explain to me what am I doing wrong?


Solution

  • If someone wondering here is correct version:

    {'(\\\"?(?:password\\\"?(=|:|>))|(?:secret\\\"?(=|:))|(?:salt\\\"?(=|:)))','\$1*******\$3'}