I am trying to run Django to work on our dev server. I read How do you register server errors on django sites , which seem to be the final answer on this topic, and copied the configuration from the answer https://stackoverflow.com/a/212960/ into my settings.py(changing the output file for WatchedFileHandler, of course, and adding my admin email address to settings.ADMINS).
Neither AdminEmailHandler nor WatchedFileHandler do what they should do when I cause a 500 error on the site. I installed settings.DEBUGin Falseand confirmed that Django can send email and write to a file. I also tried logging in directly from the Django shell:
$ /usr/local/pythonenv/DJANGO/bin/python manage.py shell
...
>>> import logging
>>> l = logging.getLogger('django')
>>> l.handlers[0]
<logging.handlers.WatchedFileHandler instance at 0xcd3b48>
>>> l.error("This should write to a file")
>>> l = logging.getLogger('django.request')
>>> l.handlers[0]
<django.utils.log.AdminEmailHandler instance at 0xcd37e8>
>>> l.error("This should email the addresses in settings.ADMINS")
In this case, no registrar issues a peep.
However, the general Python log will work (at least for the file), proving that this is not a file permissions issue:
$ python
...
>>> import logging
>>> logging.basicConfig(filename='/path/to/same/file/as/above', level=logging.DEBUG)
>>> logging.error("This one shows up")
As noted above, Django can and will happily send emails throughout my project, just not in this case.
WatchedFileHandler ( , ); AdminEmailHandler , , , Gmail , . ( - Windows 7, dev-, , - Debian 6.0.3.)
, - , , , . , , , Python, Django ?