Definition: Log4J Ignores Throwable
Our operations team wanted to strip the Throwable from the log output of a particular log or, alternately, remove the line breaks from said Throwable.
After a half-afternoon of toying, I was able to get it done reasonably easily by extending PatternLayout, adding a PatternConverter, and a few other things.
Of particular note is this: the definition of ignoresThrowable() could be a little more clear. When a Layout indicates that it ignores the Throwable, as does PatternLayout, what it really means is that Log4J should print it out after the Layout's job is done.
Accordingly, if you want to NOT print the Throwable at all, you should indicate that your Layout does not ignore the Throwable (so that Log4J won't print it) and then make sure that your Layout class doesn't print it either.
It's minor, but since this was mildly confusing to me on the first pass, I thought I'd share, so that the next person who Googles the subject can peruse this posting before digging any further.
1 comment:
Thanks a lot!!!
Post a Comment