1

Of course, I can use try and on except send email notification about error happened. But is there any better (more universal) approach? Any time exception happens (for ex., with minimum severity ERROR) - email to be sent?

Is there any ready solution or will I have to get logs and parse them for ex. each 5 minutes to generate notification?

LA_
  • 19,823
  • 58
  • 172
  • 308
  • Found similar question with good solutions and links - http://stackoverflow.com/questions/21648341/how-to-automatically-get-email-alerts-on-errors-in-google-app-engine – LA_ Apr 21 '14 at 12:51

1 Answers1

5

Have a look at ereporter - https://developers.google.com/appengine/articles/python/recording_exceptions_with_ereporter, you can then configure a cron job to send email reports.

Tim Hoffman
  • 12,976
  • 1
  • 17
  • 29
  • Thanks. After reading the article, I have a few questions - (1) Where should I put ereporter.register_logger()? Should it be in each and every .py file I have? (2) Does it capture only uncaught exceptions and exceptions logged with `logging.exception`? Can I add `logging.error` there? (3) Looks like it can not send the message immediately (only for previous day(s)), right? – LA_ Apr 20 '14 at 13:27
  • Frequency will depend on how you configure cron. You could set it to send a report every hour if you want to. – Tim Hoffman Apr 20 '14 at 14:33
  • I would put the import and register_logger() in `appengine_config.py` that way you only have to include it in one place for your enture app. Everything in appengine_config.py is loaded before any of your code is run. – Tim Hoffman Apr 20 '14 at 14:36
  • It should log `logging.exception` , that is the recommended way of logging in the event of an exception, that you are catching. – Tim Hoffman Apr 20 '14 at 14:38
  • Tim, thanks for your help. Let's say I want to receive the report each hour, then my cron url should indicate current date in the according parameter (`&date=2014-04-21`, as yesterday is used by default). How could I do it? – LA_ Apr 21 '14 at 12:51