By design, my application sometimes creates repeated errors that populate the log file and make it annoying to read. It looks like this:
WARNING:__main__:CRON10: clock unset or no wind update received in 60 sec -> supressed rrd update WARNING:__main__:CRON10: clock unset or no wind update received in 60 sec -> supressed rrd update WARNING:__main__:CRON10: clock unset or no wind update received in 60 sec -> supressed rrd update WARNING:__main__:CRON10: clock unset or no wind update received in 60 sec -> supressed rrd update
How can I use the Python logging module to suppress duplicate messages and output something more rsyslog style ( http://www.rsyslog.com/doc/rsconf1_repeatedmsgreduction.html ):
WARNING:__main__:CRON10: clock unset or no wind update received in 60 sec -> supressed rrd update
Is there a way to expand logging or do I need to write my own log?
The code I use for logging is:
logging.basicConfig(format='%(asctime)s %(message)s') logging.basicConfig(level=logging.info) logger = logging.getLogger(__name__) hdlr = logging.FileHandler(LOGFILE) hdlr.setFormatter(formatter) logger.addHandler(hdlr)
Any ideas on this?
source share