code: private InputStream logAndCloneInputStream(InputStream originalInput,
  			String logPrefix) {
  		if (!XML_LOG_ENABLED) {
  			return originalInput;
  		}
  		ByteArrayOutputStream copy = new ByteArrayOutputStream();
  		byte[] buffer = new byte[LOG_BUFFER_SIZE];
  
  		try {
  			while (true) {
  				int n = originalInput.read(buffer);
  				if (n == -1) {
  					break;
  				}
  				copy.write(buffer, 0, n);
  			}
  			Date now = new Date();
  
  			StringBuffer sb = new StringBuffer();
  			sb.append(LOGGING_DATE_FORMAT.format(now));
  			sb.append(" ");
  			sb.append(logPrefix);
  			sb.append(" - ");
  			sb.append(new String(copy.toByteArray(), "UTF-8"));
  			System.out.println(sb.toString());
  			System.out.flush();
  			return new ByteArrayInputStream(copy.toByteArray());
  		} catch (IOException e) {
  			throw new RuntimeException(e);
  		}
  	}
docs: Log the content of the given {@link InputStream} and return a copy
  of the content in a new stream. The {@link InputStream} may be empty
  after this method returns. If logging is not enabled this method
  returns the given stream object and logs nothing.
  
  @param originalInput the stream to log
  @param logPrefix a string prefix for the log message
  @return a copy of the given {@link InputStream}