code: private String preventLogForging(String logMsg) {
  
      String result = logMsg;
      // use precompiled pattern for performance reasons
      result = LINEBREAK_PATTERN.matcher(logMsg).replaceAll(SingleLinePatternLayout.LINE_SEP);
      return result;
    }
docs: Method to prevent log forging.
  
  @param logMsg
  @return Encoded message