Reputation: 3070
I'm looking for an approach that would give me the flexibility to specify what should be printed. For example, I want my stack trace to only have the filename:line_number printed. I don't want the package name and function name.
Upvotes: 2
Views: 2125
Reputation: 32980
You can write an own utility method for that:
Given an Throwable e
get the list of StackTraceElement
StackTraceElement[] elems = e.getStackTrace();
then loop over the elements and print the information you want, using StackTraceElement.getFileName()
and getLineNumber()
Upvotes: 4