Created
March 7, 2018 16:31
-
-
Save trAve3113r/27b8562127ab467c26ca8b5207e482a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # for logging a pesky '500 server error' | |
| # credits :https://stackoverflow.com/questions/238081/how-do-you-log-server-errors-on-django-sites | |
| LOGGING = { | |
| 'version': 1, | |
| 'disable_existing_loggers': False, | |
| 'handlers': { | |
| # Include the default Django email handler for errors | |
| # This is what you'd get without configuring logging at all. | |
| 'mail_admins': { | |
| 'class': 'django.utils.log.AdminEmailHandler', | |
| 'level': 'ERROR', | |
| # But the emails are plain text by default - HTML is nicer | |
| 'include_html': True, | |
| }, | |
| # Log to a text file that can be rotated by logrotate | |
| 'logfile': { | |
| 'class': 'logging.handlers.WatchedFileHandler', | |
| 'filename': '/var/log/django/myapp.log' | |
| }, | |
| }, | |
| 'loggers': { | |
| # Again, default Django configuration to email unhandled exceptions | |
| 'django.request': { | |
| 'handlers': ['mail_admins'], | |
| 'level': 'ERROR', | |
| 'propagate': True, | |
| }, | |
| # Might as well log any errors anywhere else in Django | |
| 'django': { | |
| 'handlers': ['logfile'], | |
| 'level': 'ERROR', | |
| 'propagate': False, | |
| }, | |
| # Your own app - this assumes all your logger names start with "myapp." | |
| 'myapp': { | |
| 'handlers': ['logfile'], | |
| 'level': 'WARNING', # Or maybe INFO or DEBUG | |
| 'propagate': False | |
| }, | |
| }, | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment