python自带的logging是否有自动发邮件功能

如题所述

有,使用 logging.handlers.SMTPHandler,SMTP和logging模块都需要自己配置。


如果使用163邮箱发信,这个handler可以这样配置:

h = SMTPHandler("smtp.163.com", user_mail, target_mail,
                "logging from my app",
                credentials=(user_mail, password),
                secure=())

具体怎么集成到你的logging配置,取决于你用的fileConfig, dictConfig还是别的。反正都可以配上去就是了。

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答