Counting repeating lines instead of displaying all

2019-07-18 06:12发布

问题:

I have seen a log once that looked like this. Not sure what logging framework generated it.

12:34:56 INFO blah
... previous line repeated 23 times
11:22:33 DEBUG blah

Can this be done with log4j2?

回答1:

The current version, Log4j 2.6.2, does not have this capability. I'm not sure how easy it would be to implement this, but I would definitely recommend that you raise a feature request for this on the Log4j 2 issue tracker.

A similar request may already exist to suppress repeated stack traces, but I think your idea is different enough to warrant a separate Jira ticket.