@Test public void testMask() { String layoutMessage = log("This message contains SSN 123-45-6789"); System.out.println("testMask() layoutMessage: " + layoutMessage); assertFalse(layoutMessage.contains("123-45-6789")); assertTrue(layoutMessage.contains("***-**-6789")); }
private String mask(String formattedMessage) { Matcher matcher = SSN_PATTERN.matcher(formattedMessage); while (matcher.find()) { String found = matcher.group(); StringBuilder builder = new StringBuilder(); builder.append("***-**-"); builder.append(found.substring(7)); formattedMessage = formattedMessage.replaceAll(found, builder.toString()); } return formattedMessage; }
SSNMaskingConverter extends ClassicConverter { private String mask(String formattedMessage) { Matcher matcher = SSN_PATTERN.matcher(formattedMessage); while (matcher.find()) { String found = matcher.group(); StringBuilder builder = new StringBuilder(); builder.append("***-**-"); builder.append(found.substring(7)); formattedMessage = formattedMessage.replaceAll(found, builder.toString()); } return formattedMessage; } }
SSNMaskingConverter extends ClassicConverter { private String mask(String formattedMessage) { Matcher matcher = SSN_PATTERN.matcher(formattedMessage); while (matcher.find()) { String found = matcher.group(); StringBuilder builder = new StringBuilder(); builder.append("***-**-"); builder.append(found.substring(7)); formattedMessage = formattedMessage.replaceAll(found, builder.toString()); } return formattedMessage; }  }
SSNMaskingConverter extends ClassicConverter { private String mask(String formattedMessage) { Matcher matcher = SSN_PATTERN.matcher(formattedMessage); while (matcher.find()) { String found = matcher.group(); StringBuilder builder = new StringBuilder(); builder.append("***-**-"); builder.append(found.substring(7)); formattedMessage = formattedMessage.replaceAll(found, builder.toString()); } return formattedMessage; }  @Override String convert(ILoggingEvent iLoggingEvent); }
SSNMaskingConverter extends ClassicConverter { private String mask(String formattedMessage) { Matcher matcher = SSN_PATTERN.matcher(formattedMessage); while (matcher.find()) { String found = matcher.group(); StringBuilder builder = new StringBuilder(); builder.append("***-**-"); builder.append(found.substring(7)); formattedMessage = formattedMessage.replaceAll(found, builder.toString()); } return formattedMessage; }  @Override String convert(ILoggingEvent iLoggingEvent);  }