Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Log4J Layout/Formatter that prunes Stack Traces for exceptions?

I'm looking for a Log4J Layout/Formatter that helps me prune stack-traces in exceptions a little better than the defaults. That the stack-execution is somewhere below main() is quite obvious and unnecessary for me to know, and that the exception occurred deeply within some other library is really nothing I can do too much about.

What I would like is a Layout that trims the stack-trace to, say the last 5 method-calls of method within my own code, identified by containing jar-file, package or something else.

Is there something along these lines, or do I have to write some magic myself?

like image 257
Rawler Avatar asked Jan 26 '26 22:01

Rawler


1 Answers

I asked a similar question (about completely suppressing the stack trace a while back.

Unfortunately, there is no setting for that, you need to subclass PatternLayout to do it.

like image 166
Thilo Avatar answered Jan 28 '26 12:01

Thilo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!