I'm not seeing log entries (at a level of INFO
) made by Django in my Heroku logs.
This is my configuration:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse',
},
'require_debug_true': {
'()': 'django.utils.log.RequireDebugTrue',
},
'not_development_filter': {
'()': NotDevelopmentFilter,
},
},
'handlers': {
'console':{
'level': 'INFO',
'class': 'logging.StreamHandler',
},
'null': {
'class': 'django.utils.log.NullHandler',
},
'mail_admins': {
'level': 'ERROR',
'filters': ['not_development_filter'],
'class': 'django.utils.log.AdminEmailHandler',
'include_html': True,
}
},
'loggers': {
'': {
'handlers': ['mail_admins', 'console'],
'level': 'INFO',
},
'django': {
'handlers': ['console'],
},
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': False,
},
'py.warnings': {
'handlers': ['console'],
},
}
}
I'd like to see the log entries in the Heroku interface. Any idea why I'm not seeing them there?
In the python-getting-started app, for a log that isn't tagged
django
,ERROR
level logs show up inheroku
logs, butINFO
logs don't.To make it work for logs that aren't tagged
django
, it needs a config like the following (similar to yours):So if you adjust your configuration to otherwise be like python-getting-started, including the Procfile, it should hopefully work.
Here's a log that isn't tagged django, that I added to
views/hello.py
:When I first tried it, only the error log showed up. When I added the logging config in the code snippet above the previous one, the info and the error logs showed up. This is all with
DEBUG = False
(changed from the code in the repo, which hasDEBUG = True
).It probably is better to, rather than have the empty string key, so everything is logged, to have a more specific
loggers
entries than just the empty string (''
).Finally, in your log file, there's a case where INFO logs won't appear on the console, or Heroku logs: If it's an INFO log to
django.request
, with your config it will only go to'mail_admins'
becausepropagate
isFalse
. I think that in this case, it would make more sense forpropagate
to be set toTrue
.I had the same thing that
INFO
level does not show up but in my case (and as @Benjamin Atkin reports as well)ERROR
did.The core problem seems to be that this call:
removes whatever custom loggers you might have setup in your
LOGGING
dict.The solution is to add this to the call so that it does not mess with your logging setup:
Or better yet don't use it at all, since this package is deprecated anyway.