I am trying to set up a Django log to file. Based on https://stackoverflow.com/a/19257221/214742 I came up with the following configuration:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'console':{
'level':'DEBUG',
'class':'logging.StreamHandler',
'formatter': 'simple'
},
'applogfile': {
'level':'DEBUG',
'class':'logging.handlers.RotatingFileHandler',
'filename': os.path.join(PROJECT_ROOT, 'MODELINGWEB.log'),
'maxBytes': 1024*1024*15, # 15MB
'backupCount': 10,
'formatter': 'simple'
},
},
'loggers': {
'': {
'level': 'DEBUG',
'handlers': ['console','applogfile']
},
},
}
Now when I try to run and load a page my console log looks like:
Performing system checks...
System check identified no issues (0 silenced).
June 28, 2017 - 10:18:22
Django version 1.11, using settings 'Modeling.settings.dev'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[28/Jun/2017 10:18:27] "GET / HTTP/1.1" 200 12564
I also get a file MODELINGWEB.log
but it is empty. Why is that? I was expecting it to contain the same things...