By reading the official django documentation I haven’t understood much about it.
https://docs.djangoproject.com/en/dev/topics/logging/#configuring-logging
I would like to enable logging also if DEBUG in settings.py is set to True.
I would like the errors to be logged in a file.
How to do that?
These are the default django settings for logging which I currently have now:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
PS:
I’m using Apache + mod_wsgi in my development environment because I use a development machine which i access remotely on my LAN, this means i’m not using the django development server and I can’t see the console log messages.
Django logging is not disabled by default in either DEBUG mode unless you have set it to.
Add below to your
handlerspart ofLOGGINGIt will log to
myapp.logfile in your project root. You can specify a complete path.And add a formatters field to the Logging dict