public static StringBuilder getStackTrace(Thread targetThread) {
    StringBuilder sb = new StringBuilder(500);
    StackTraceElement[] els = targetThread.getStackTrace();
    sb.append("Stack trace for '").append(targetThread).append("'").append(lineSeparator());
    if (els.length > 0) {
      for (final StackTraceElement el : els) {
        sb.append("\tat ").append(el).append(lineSeparator());
      }
    } else {
      sb.append("    no stack").append(lineSeparator());
    }
    return sb;
  }
Utility to get a stack trace for a thread
geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterImpl.java