Log4j Stack Trace Pruning

Posted by Zubair Khan on in Java, log4j, open source, OSGi, Spring

Anyone who has ever worked with third-party Java frameworks such as Spring and OSGi can testify to how much these frameworks bloat the logged stack traces. When debugging, the last thing you want is to waste valuable energy and brain power, no matter how little, on scanning through dozens of stack frames for the relevant ones. When frameworks such as Spring and OSGi are involved, it’s usually the case that less than 5-10% of the stack frames are actually relevant (see screenshots below).

After dealing with this for years, I finally decided to extend log4j and prune out the superfluous stack frames. We thought this might be useful for others as well, so we’ve open sourced the code on GitHub.¬†Feel free to drop a line and let us know if you find it beneficial.

Stack Trace (before):


before (cont.)







Stack Trace (after):


Be the first to write a comment.


You must be logged in to post a comment.