logger.info not working in Django logging
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Puzzle4
--
Chapters
00:00 Logger.Info Not Working In Django Logging
01:29 Accepted Answer Score 7
01:59 Answer 2 Score 3
02:43 Thank you
--
Full question
https://stackoverflow.com/questions/6278...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #logging #djangologging
#avk47
ACCEPTED ANSWER
Score 7
It's probably because your views module doesn't have a logging level set, so it will inherit the root logger's default level of WARNING. If you add a root entry with a level of INFO, similarly to the documented examples, you should see messages from other modules. Alternatively you can specify logger names under the loggers key for your specific module hierarchy, whatever that is. (Your example only overrides the WARNING level for modules in the django hierarchy, i.e. code in Django itself.)
ANSWER 2
Score 3
In the example you provided, you are only setting the log level for the 'django' logger. That logger controls the log level for django.request, django.server, django.templateetc. If you are looking to set the log level for your own apps, you need to set the log level for that particular app's logger, or set it for all apps using a configuration like below
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console_handler': {
'class': 'logging.StreamHandler',
},
},
'loggers': {
# More info on '' (unnamed) loggers at the end of this comment
'': {
'level': 'INFO',
'handlers': ['console_handler'],
},
},
}
The '' (unnamed) logger will process records from all loggers. More info here: https://docs.djangoproject.com/en/dev/howto/logging/#configure-a-logger-mapping