How to filter specific lines from log4j stack trace?

I want to filter specific lines from stack traces using log4j (e.g. net.sf.cglib.* And org.springframework.* ). Is it possible to configure this with log4j ?

In eclipse, the junit plugin allows you to add filters that modify the stack traces displayed on the junit tab, but this does not change the stack traces displayed on the console.

+6
source share
2 answers

Use this log4j add-on filtering layout: http://www.openmindlab.com/lab/tools/openutilslog4j/layout.html

They have an example with log4j.xml on this page. Just use it.openutils.log4j.FilteredPatternLayout instead of log4j PatternLayout and then put some entries like

  <param name="Filter" value="net.sf.cglib"/> <param name="Filter" value="org.springframework"/> 

below.

+2
source

I just published an open source library that filters stack trace very well. Here is a link to a small article on the library: MgntUtils open source Java library. There is also a link to sources on github: https://github.com/michaelgantman/Mgnt, and here is a Maven link to the library.

+1
source

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


All Articles