public static void logStackTrace(final String message,
                                     final Consumer<String> logConsumer) {
        if (logConsumer != null) {
            try {
                final Writer writer = new StringWriter();
                final PrintWriter pw = new PrintWriter(writer);
                new Exception("Dumping Stack Trace").printStackTrace(pw);
                logConsumer.accept(
                        Objects.requireNonNullElse(message, "Dumping stack trace") + "\n" + writer);
            } catch (Exception e) {
                logConsumer.accept(
                        "Error dumping stack trace: " + e.getMessage());
            }
        }
    }
Log the current thread's stack trace to the logConsumer, prefixed with message and a new line.
stroom-util/src/main/java/stroom/util/logging/LogUtil.java