I have a Django application that I am migrating from v1.8 to v1.10. In the process of doing this work, I ran my application via:
python -Wall manage.py runserver
Doing so causes a number of Python warnings to appear in my console. I'd like to have these warnings show up in my Django application log, so I can examine them later. I thought my application's log handler would catch these warnings, but it doesn't. The log handler looks like the following (as taken from settings.py):
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
'datefmt': "%d/%b/%Y %H:%M:%S"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'file': {
'level': 'WARNING',
'class': 'logging.FileHandler',
'filename': 'myapp.log',
'formatter': 'verbose'
},
},
'loggers': {
'django': {
'handlers': ['file'],
'propagate': True,
'level': 'WARNING',
},
'myapp': {
'handlers': ['file'],
'level': 'WARNING',
},
}
}
How can I capture Python warnings (with -Wall
) in my Django log for examination later?