public static void put(PrintWriter log, String msg, Throwable exception) {
    java.io.StringWriter sw = new java.io.StringWriter();
    String header;
    PrintWriter pw = new PrintWriter(sw);

    pw.println();
    header = '[' + getTimeStamp() + ' ' + Thread.currentThread().getName() + "] ";
    pw.print(header);
    if (msg != null) {
      try {
        formatText(pw, msg, LOGWIDTH, header.length());
      } catch (RuntimeException e) {
        pw.println(msg);
        pw.println("Ignoring exception:");
        e.printStackTrace(pw);
      }
    } else {
      pw.println();
    }
    if (exception != null) {
      exception.printStackTrace(pw);
    }
    pw.close();
    try {
      sw.close();
    } catch (java.io.IOException ignore) {
    }

    if (log == null) {
      log = logWriter;
    }
    log.print(sw);
    log.flush();
  }
Logs a message and an exception to the specified log destination.

@param log the <code>PrintWriter</code> that the message will be written to. If null then the
       default stdout writer is used.
@param msg the actual message to log
@param exception the actual Exception to log
geode-core/src/test/java/org/apache/persistence/admin/Logger.java