public String convert(ILoggingEvent event) {
    String formattedMessage = event.getFormattedMessage();
    if (formattedMessage != null) {
      String result = CR_PATTERN.matcher(formattedMessage).replaceAll("\\\\r");
      result = LF_PATTERN.matcher(result).replaceAll("\\\\n");
      return result;
    }
    return null;
  }
@Test
  public void convert_message_with_CR() {
    ILoggingEvent event = createILoggingEvent("simple\r message\r with\r CR\r");
    assertThat(underTest.convert(event)).isEqualTo("simple\\r message\\r with\\r CR\\r");
  }