I want to create two different loggers so that users see one output (e.g. no exception/stack traces) and others (e.g support staff) that does see stack traces via email. The code below is close but I still get console output on the email logger from the "root" logger. How do I get rid of it?
import logging import logging.handlers def main(): console = logging.StreamHandler() console.setFormatter(logging.Formatter('%(asctime)s %(message)s')) console.setLevel(logging.CRITICAL) logging.getLogger('').addHandler(console) mail = logging.handlers.SMTPHandler('mail.vw.com', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]', 'Data Processing Error at location: %s' % "Chuck's Desk") mail.setFormatter(logging.Formatter('%(asctime)s %(message)s')) logging.getLogger('mail').addHandler(mail) try: raise Exception("foobar") except Exception, e: logging.getLogger('').error(e) print "Done logging to console" logging.getLogger('mail').exception(e) if __name__ == "__main__": main() -- http://mail.python.org/mailman/listinfo/python-list