1
I suggest you to take a look a the several handy ways to log errors with django.
For production, you will want to configure your logging behavior.
You can find an example here in the same docs.
What I personally do in production is enabling email logging, it sends me an email each time there is a fatal error.
Letβs see what it would look like for logging both by mail and in a file:
settings.py
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
},
'logfile': {
'class': 'logging.handlers.WatchedFileHandler',
'filename': '/var/log/django/your_application.log'
},
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'django': {
'handlers': ['logfile'],
'level': 'ERROR',
'propagate': False,
},
}
}
Source:stackexchange.com