0

EDIT - just using the standard logger from python

I have a SMTP logging handler that looks like:

import logging, logging.handlers

# Logging to a file done here
rootLogger = logging.getLogger()
loggingHandler = logging.FileHandler (LOG_FILE)
loggingFormatter = logging.Formatter ('%(asctime)s %(levelname)s %(name)s %(message)s')
loggingHandler.setFormatter (loggingFormatter)
rootLogger.setLevel (logging.DEBUG)
rootLogger.addHandler (loggingHandler)

# Logging to email of any errors
emailHandler = logging.handlers.SMTPHandler ("localhost", "me@localhost", ["me@awesome.edu"], "Backup Error")
emailHandler.setFormatter (loggingFormatter)
emailHandler.setLevel (logging.ERROR)
rootLogger.addHandler (emailHandler)

The problem I'm having is each time there is an error, I get one email per error message. For the rsync automation that this logger handles, sometimes there can be thousands. Is there a way to get one email with the entire error logging, or even debug logging, from this script in one large email instead of thousands of small ones?

jwillis0720
  • 4,329
  • 8
  • 41
  • 74
  • I'm sure there is a way. It'll depend upon your logger (does it do it already?) and then your ability to add additional steps to send digest errors instead of each one... – AlG Apr 22 '15 at 18:33
  • Sorry, added the logger im using (just standard built in one) – jwillis0720 Apr 22 '15 at 18:36
  • @jwillis0720: There is a link to the original question at the top of this page. – unutbu Apr 22 '15 at 18:58
  • 1
    http://stackoverflow.com/q/8191721/190597 may be a better dupe target, but the answer is on http://stackoverflow.com/q/1610845/190597. – unutbu Apr 22 '15 at 19:12

0 Answers0