class DuplicateFilter(object):

    def __init__(self):
        self.msgs = set()

def filter(self, record):
    rv = record.msg not in self.msgs
self.msgs.add(record.msg)
return rv
dup_filter = DuplicateFilter()
logger.addFilter(dup_filter)
for i in range(10):
    pass
Python logging: print message only once