3
GAE可以配置爲在發生錯誤時給我發電子郵件嗎?GAE給我發郵件錯誤
GAE可以配置爲在發生錯誤時給我發電子郵件嗎?GAE給我發郵件錯誤
我認爲你能做的最好是在你的main
功能有一些這樣的代碼...:
try:
...normal body of your main goes here...
except:
from google.appengine.api import mail
import sys
mail.send_mail(sender="Your GAE App <[email protected]>",
to="You <[email protected]>",
subject="GAE App error",
body="""
Your App Engine app raised an exception:
%s
""" % sys.exc_info()[:2])
(當然,你可以做的更好的異常信息的格式,等等等等) 。
以下是使用GAE發送電子郵件的示例。你可以建立在這個例子中捕捉異常,併發送一封郵件給自己....
http://www.fishbonecloud.com/2010/11/automated-email-using-google-app-engine.html
只是當你結束了每分鐘幾百封電子郵件;-)如果不感到驚訝您的負載很高,將異常存儲在數據庫中,並使用cron作業定期通過電子郵件發送(或摘要)。 – Wim 2010-01-22 18:58:51