Is there a Log4J Layout / Formatter that handles stack traces for exceptions?

I am looking for a Log4J Layout / Formatter that helps me trim stack traces in exceptions a little better than the defaults. The fact that the execution of the stack is somewhere below main () is completely obvious and not necessary for me to know, and that the exception occurred deep inside some other library, in fact I can do nothing too much.

I would like to create a layout that cuts off the stack trace, for example, the last 5 method call methods in my own code, identified by a jar file, package, or something else.

Is there anything in this direction, or do I need to write some kind of magic?

+3
source share
5 answers

I also looked for this, but did not find anything satisfactory, so I wrote my own ThrowableRenderer, which cuts the external frames of the stack. I have opened the source code for other users. Check out my blog post ; You can find the link to the code there.

+1
source

I asked a similar question (about completely disabling stack tracing back.

Unfortunately, there are no settings for this, you need to subclass PatternLayout to do this.

+2
source

"ex" "" logback-classic ( log4j) . "ex" . .

, , -.

+1

:

  • , -
  • (/)
  • , ,
0

You can write a custom Appender that has the special logic that you need. This can be a good way.

0
source

Source: https://habr.com/ru/post/1707909/


All Articles