java - Logging with log4j only once every so many calls to logger.info/debug/warn() calls -


i have scenario particular log message might printed lot of times (may in millions). example, if log (using logger.warn() method)for every record missing field(s), might end logging lot-cases input file has lot of records missing fields(for example, large files on hdfs). fills disk space.

to avoid situation, trying log once every (for example) 1000 records missing fields. can implement of logic outside of log4j package, wondering if there cleaner way this. ideally, of logic go log4j code.

this seems commonly encountered problem, there hardly info on this. thoughts?

log4j cant out of box. may try write own listener. if want switch logback logging framework, there filter called duplicatemessagefilter drops messages after repetition. should consider this, because logging surely impact on performance. logback configured same way log4j , supports slf4j out of box.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -