Python3-日志记录-使用exc_info发送电子邮件

时间:2018-11-12 08:00:43

标签: python-3.x logging

我正在使用python3中的日志记录包来记录错误或警告。我需要针对任何错误以及堆栈跟踪内容触发一封电子邮件。考虑以下代码块:

try:
 dosomething()
except Exception as e:
  message = "Error occured while processing message Exception {}".format(e)
  logging.critical(message,exc_info=True)

我需要发送带有exc_info的通知。如果我正在发送消息,则唯一的基本错误是与邮件一起发生的,而不是堆栈跟踪。

请帮助。

0 个答案:

没有答案