diff --git a/libs/reactive-core/src/main/java/no/nav/testnav/libs/reactivecore/logging/TestnavLogbackEncoder.java b/libs/reactive-core/src/main/java/no/nav/testnav/libs/reactivecore/logging/TestnavLogbackEncoder.java index 67acbbe5fee..3f43eac0b06 100644 --- a/libs/reactive-core/src/main/java/no/nav/testnav/libs/reactivecore/logging/TestnavLogbackEncoder.java +++ b/libs/reactive-core/src/main/java/no/nav/testnav/libs/reactivecore/logging/TestnavLogbackEncoder.java @@ -33,8 +33,8 @@ public class TestnavLogbackEncoder extends LogstashEncoder { // matches exactly 11 digits (\\d{11}) that are not immediately preceded ((? { + if (match.group().charAt(2) == '0' || match.group().charAt(2) == '1') { + return match.group().substring(0, 6) + "xxxxx"; } - } - matcher.appendTail(result); + return match.group(); + }); + + message = bearer.matcher(message).replaceAll("REDACTED_BEARER"); - return result.toString(); + return message; } } \ No newline at end of file