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 TypeMethodDescriptionvoid
printStackTrace
(Throwable throwable, Appendable out) Prints a stack trace for the givenThrowable
.static StandardStackTracePrinter
Return aStandardStackTracePrinter
that prints the stack trace with the root exception first (the opposite ofThrowable.printStackTrace()
).static StandardStackTracePrinter
rootLast()
Return aStandardStackTracePrinter
that prints the stack trace with the root exception last (the same asThrowable.printStackTrace()
).Return a newStandardStackTracePrinter
from this one that will print all common frames rather the replacing them with the "... N more" message.withFilter
(Predicate<Throwable> predicate) Return a newStandardStackTracePrinter
from this one that will only include throwables (excluding caused and suppressed) that match the given predicate.withFormatter
(Function<Throwable, String> formatter) Return a newStandardStackTracePrinter
from this one uses the specified formatter to create a string representation of a throwable.withFrameFilter
(BiPredicate<Integer, StackTraceElement> predicate) Return a newStandardStackTracePrinter
from this one that will only include frames that match the given predicate.withFrameFormatter
(Function<StackTraceElement, String> frameFormatter) Return a newStandardStackTracePrinter
from this one uses the specified formatter to create a string representation of a frame.Return a newStandardStackTracePrinter
from this one that generates and prints hashes for each stacktrace.withHashes
(boolean hashes) Return a newStandardStackTracePrinter
from this one that changes if hashes should be generated and printed for each stacktrace.withHashes
(ToIntFunction<StackTraceElement> frameHasher) withLineSeparator
(String lineSeparator) Return a newStandardStackTracePrinter
from this one that print the stack trace using the specified line separator.withMaximumLength
(int maximumLength) Return a newStandardStackTracePrinter
from this one that will use ellipses to truncate output longer that the specified length.withMaximumThrowableDepth
(int maximumThrowableDepth) Return a newStandardStackTracePrinter
from this one that filter frames (including caused and suppressed) deeper then the specified maximum.Return a newStandardStackTracePrinter
from this one that will not printsuppressed
items.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.boot.logging.StackTracePrinter
printStackTraceToString
-
Method Details
-
printStackTrace
Description copied from interface:StackTracePrinter
Prints a stack trace for the givenThrowable
.- Specified by:
printStackTrace
in 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 newStandardStackTracePrinter
from this one that will print all common frames rather the replacing them with the "... N more" message.- Returns:
- a new
StandardStackTracePrinter
instance
-
withoutSuppressed
Return a newStandardStackTracePrinter
from this one that will not printsuppressed
items.- Returns:
- a new
StandardStackTracePrinter
instance
-
withMaximumLength
Return a newStandardStackTracePrinter
from 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
StandardStackTracePrinter
instance
-
withMaximumThrowableDepth
Return a newStandardStackTracePrinter
from this one that filter frames (including caused and suppressed) deeper then the specified maximum.- Parameters:
maximumThrowableDepth
- the maximum throwable depth- Returns:
- a new
StandardStackTracePrinter
instance
-
withFilter
Return a newStandardStackTracePrinter
from 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
StandardStackTracePrinter
instance
-
withFrameFilter
Return a newStandardStackTracePrinter
from this one that will only include frames that match the given predicate.- Parameters:
predicate
- the predicate used to filter frames- Returns:
- a new
StandardStackTracePrinter
instance
-
withLineSeparator
Return a newStandardStackTracePrinter
from this one that print the stack trace using the specified line separator.- Parameters:
lineSeparator
- the line separator to use- Returns:
- a new
StandardStackTracePrinter
instance
-
withFormatter
Return a newStandardStackTracePrinter
from this one uses the specified formatter to create a string representation of a throwable.- Parameters:
formatter
- the formatter to use- Returns:
- a new
StandardStackTracePrinter
instance - See Also:
-
withFrameFormatter
public StandardStackTracePrinter withFrameFormatter(Function<StackTraceElement, String> frameFormatter) Return a newStandardStackTracePrinter
from this one uses the specified formatter to create a string representation of a frame.- Parameters:
frameFormatter
- the frame formatter to use- Returns:
- a new
StandardStackTracePrinter
instance - See Also:
-
withHashes
Return a newStandardStackTracePrinter
from this one that generates and prints hashes for each stacktrace.- Returns:
- a new
StandardStackTracePrinter
instance
-
withHashes
Return a newStandardStackTracePrinter
from this one that changes if hashes should be generated and printed for each stacktrace.- Parameters:
hashes
- if hashes should be added- Returns:
- a new
StandardStackTracePrinter
instance
-
withHashes
-
rootLast
Return aStandardStackTracePrinter
that prints the stack trace with the root exception last (the same asThrowable.printStackTrace()
).- Returns:
- a
StandardStackTracePrinter
that prints the stack trace root last
-
rootFirst
Return aStandardStackTracePrinter
that prints the stack trace with the root exception first (the opposite ofThrowable.printStackTrace()
).- Returns:
- a
StandardStackTracePrinter
that prints the stack trace root first
-