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 ebaf3ca809d..dca76cb513d 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) < '4') { - return match.group().substring(0, 6) + "xxxxx"; - } - return match.group(); - }); - message = bearer.matcher(message).replaceAll("REDACTED_BEARER"); + message = IDENT.matcher(message).replaceAll(match -> + + match.group().charAt(2) < '4' ? + match.group().substring(0, 6) + "xxxxx" : + match.group().substring(0, 11) + "x" + ); - return message; + return BEARER.matcher(message).replaceAll("Bearer token"); } } diff --git a/libs/servlet-core/src/main/java/no/nav/testnav/libs/servletcore/logging/TestnavLogbackEncoder.java b/libs/servlet-core/src/main/java/no/nav/testnav/libs/servletcore/logging/TestnavLogbackEncoder.java index 2158548eb68..a82cd5c197e 100644 --- a/libs/servlet-core/src/main/java/no/nav/testnav/libs/servletcore/logging/TestnavLogbackEncoder.java +++ b/libs/servlet-core/src/main/java/no/nav/testnav/libs/servletcore/logging/TestnavLogbackEncoder.java @@ -33,7 +33,8 @@ public class TestnavLogbackEncoder extends LogstashEncoder { // matches exactly 11 digits (\\d{11}) that are not immediately preceded ((? - while (matcher.find()) { - var match = matcher.group(); - if (match.charAt(2) == '0' || match.charAt(2) == '1') { - var replacement = match.substring(0, 6) + "xxxxx"; - matcher.appendReplacement(result, replacement); - } - } - matcher.appendTail(result); + match.group().charAt(2) < '4' ? + match.group().substring(0, 6) + "xxxxx" : + match.group().substring(0, 11) + "x" + ); - return result.toString(); + return BEARER.matcher(message).replaceAll("Bearer token"); } } \ No newline at end of file