How to do it...

The following procedure will help you to send detailed emails about errors:

  1. If you do not already have LOGGING settings set up for your project, set those up first. Find the Django logging utilities file, available at lib/python3.6/site-packages/django/utils/log.py. This lib/ directory will be in either your virtual environment myproject_env/ or /usr/local/ in a Docker project's app container. You can open the file in a text editor (or via the more command in a terminal) and copy the DEFAULT_LOGGING dictionary to your project's settings.py as the LOGGING dictionary.
  2. Add the include_html setting to the mail_admins handler. The result of the first two steps should be something like the following:
# settings.py or conf/base.py
DEFAULT_LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse',
},
'require_debug_true': {
'()': 'django.utils.log.RequireDebugTrue',
},
},
'formatters': {
'django.server': {
'()': 'django.utils.log.ServerFormatter',
'format': '[{server_time}] {message}',
'style': '{',
}
},
'handlers': {
'console': {
'level': 'INFO',
'filters': ['require_debug_true'],
'class': 'logging.StreamHandler',
},
'django.server': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'django.server',
},
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler',
'include_html': True,
}
},
'loggers': {
'django': {
'handlers': ['console', 'mail_admins'],
'level': 'INFO',
},
'django.server': {
'handlers': ['django.server'],
'level': 'INFO',
'propagate': False,
},
}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.232.152