Package org.springframework.boot.logging
Class StandardStackTracePrinter
java.lang.Object
org.springframework.boot.logging.StandardStackTracePrinter
- All Implemented Interfaces:
StackTracePrinter
StackTracePrinter that prints a standard form stack trace. This printer
produces a result in a similar form to Throwable.printStackTrace(), but offers
more customization options.- Since:
- 3.5.0
- Author:
- Phillip Webb
-
Method Summary
Modifier and TypeMethodDescriptionvoidprintStackTrace(Throwable throwable, Appendable out) Prints a stack trace for the givenThrowable.static StandardStackTracePrinterReturn aStandardStackTracePrinterthat prints the stack trace with the root exception first (the opposite ofThrowable.printStackTrace()).static StandardStackTracePrinterrootLast()Return aStandardStackTracePrinterthat prints the stack trace with the root exception last (the same asThrowable.printStackTrace()).Return a newStandardStackTracePrinterfrom this one that will print all common frames rather the replacing them with the "... N more" message.withFilter(Predicate<Throwable> predicate) Return a newStandardStackTracePrinterfrom this one that will only include throwables (excluding caused and suppressed) that match the given predicate.withFormatter(Function<Throwable, String> formatter) Return a newStandardStackTracePrinterfrom this one uses the specified formatter to create a string representation of a throwable.withFrameFilter(BiPredicate<Integer, StackTraceElement> predicate) Return a newStandardStackTracePrinterfrom this one that will only include frames that match the given predicate.withFrameFormatter(Function<StackTraceElement, String> frameFormatter) Return a newStandardStackTracePrinterfrom this one uses the specified formatter to create a string representation of a frame.Return a newStandardStackTracePrinterfrom this one that generates and prints hashes for each stacktrace.withHashes(boolean hashes) Return a newStandardStackTracePrinterfrom this one that changes if hashes should be generated and printed for each stacktrace.withHashes(ToIntFunction<StackTraceElement> frameHasher) withLineSeparator(String lineSeparator) Return a newStandardStackTracePrinterfrom this one that print the stack trace using the specified line separator.withMaximumLength(int maximumLength) Return a newStandardStackTracePrinterfrom this one that will use ellipses to truncate output longer that the specified length.withMaximumThrowableDepth(int maximumThrowableDepth) Return a newStandardStackTracePrinterfrom this one that filter frames (including caused and suppressed) deeper then the specified maximum.Return a newStandardStackTracePrinterfrom this one that will not printsuppresseditems.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.boot.logging.StackTracePrinter
printStackTraceToString
-
Method Details
-
printStackTrace
Description copied from interface:StackTracePrinterPrints a stack trace for the givenThrowable.- Specified by:
printStackTracein interfaceStackTracePrinter- Parameters:
throwable- the throwable that should have its stack trace printedout- the destination to write output- Throws:
IOException- on IO error
-
withCommonFrames
Return a newStandardStackTracePrinterfrom this one that will print all common frames rather the replacing them with the "... N more" message.- Returns:
- a new
StandardStackTracePrinterinstance
-
withoutSuppressed
Return a newStandardStackTracePrinterfrom this one that will not printsuppresseditems.- Returns:
- a new
StandardStackTracePrinterinstance
-
withMaximumLength
Return a newStandardStackTracePrinterfrom this one that will use ellipses to truncate output longer that the specified length.- Parameters:
maximumLength- the maximum length that can be printed- Returns:
- a new
StandardStackTracePrinterinstance
-
withMaximumThrowableDepth
Return a newStandardStackTracePrinterfrom this one that filter frames (including caused and suppressed) deeper then the specified maximum.- Parameters:
maximumThrowableDepth- the maximum throwable depth- Returns:
- a new
StandardStackTracePrinterinstance
-
withFilter
Return a newStandardStackTracePrinterfrom this one that will only include throwables (excluding caused and suppressed) that match the given predicate.- Parameters:
predicate- the predicate used to filter the throwable- Returns:
- a new
StandardStackTracePrinterinstance
-
withFrameFilter
Return a newStandardStackTracePrinterfrom this one that will only include frames that match the given predicate.- Parameters:
predicate- the predicate used to filter frames- Returns:
- a new
StandardStackTracePrinterinstance
-
withLineSeparator
Return a newStandardStackTracePrinterfrom this one that print the stack trace using the specified line separator.- Parameters:
lineSeparator- the line separator to use- Returns:
- a new
StandardStackTracePrinterinstance
-
withFormatter
Return a newStandardStackTracePrinterfrom this one uses the specified formatter to create a string representation of a throwable.- Parameters:
formatter- the formatter to use- Returns:
- a new
StandardStackTracePrinterinstance - See Also:
-
withFrameFormatter
public StandardStackTracePrinter withFrameFormatter(Function<StackTraceElement, String> frameFormatter) Return a newStandardStackTracePrinterfrom this one uses the specified formatter to create a string representation of a frame.- Parameters:
frameFormatter- the frame formatter to use- Returns:
- a new
StandardStackTracePrinterinstance - See Also:
-
withHashes
Return a newStandardStackTracePrinterfrom this one that generates and prints hashes for each stacktrace.- Returns:
- a new
StandardStackTracePrinterinstance
-
withHashes
Return a newStandardStackTracePrinterfrom this one that changes if hashes should be generated and printed for each stacktrace.- Parameters:
hashes- if hashes should be added- Returns:
- a new
StandardStackTracePrinterinstance
-
withHashes
-
rootLast
Return aStandardStackTracePrinterthat prints the stack trace with the root exception last (the same asThrowable.printStackTrace()).- Returns:
- a
StandardStackTracePrinterthat prints the stack trace root last
-
rootFirst
Return aStandardStackTracePrinterthat prints the stack trace with the root exception first (the opposite ofThrowable.printStackTrace()).- Returns:
- a
StandardStackTracePrinterthat prints the stack trace root first
-