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.handler s
def main():
console = logging.StreamH andler()
console.setForm atter(logging.F ormatter('%(asc time)s %(message)s'))
console.setLeve l(logging.CRITI CAL)
logging.getLogg er('').addHandl er(console)
mail = logging.handler s.SMTPHandler(' mail.vw.com',
'm********@myco mpany.com',
'm********@myco mpany.com',
'Data Processing Error at
location: %s' % "Chuck's Desk")
mail.setFormatt er(logging.Form atter('%(asctim e)s %(message)s'))
logging.getLogg er('mail').addH andler(mail)
try:
raise Exception("foob ar")
except Exception, e:
logging.getLogg er('').error(e)
print "Done logging to console"
logging.getLogg er('mail').exce ption(e)
if __name__ == "__main__":
main()