Django Error Logging
I am using Django + Python + Gunicorn + Nginx + MySQL stack to make a
social dating website - http://www.tomonotomo.com
My settings.py file in Django is as follows:
DEBUG = False
TEMPLATE_DEBUG = False
ADMINS = (
('Pratik Poddar', 'xxxxxxxxxxx'),
)
MANAGERS = ADMINS
FAILED_RUNS_CRONJOB_EMAIL_PREFIX = "[Django - Tomonotomo - Cron Job] "
EMAIL_SUBJECT_PREFIX = "[Django - Tomonotomo] "
.....
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d
%(thread)d %(message)s'
}
},
'handlers': {
'null': {
'level': 'INFO',
'class': 'logging.NullHandler'
},
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django': {
'handlers': ['null'],
'level': 'INFO',
'propagate': True,
},
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
My gunicorn config is as follows:
stdout_logfile = /home/ubuntu/gunicorn_tomonotomo_supervisor.log
redirect_stderr = true
My nginx config has :
access_log /home/ubuntu/tomonotomo-access.log;
error_log /home/ubuntu/tomonotomo-error.log error;
I am not able to see my error log. I do not want to make debug = True as
it is in production. I am not getting any mails as well.
I am looking to get have all the logs in a file and have all the errors
emailed me every day in the morning. How can I implement that?
Thanks a ton
No comments:
Post a Comment