#24361 closed Bug (fixed)
The doc is not right w.r.t. LOGGING overwriting.
Reported by: | Vlada Macek | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The https://github.com/django/django/blob/master/docs/topics/logging.txt says
If the
disable_existing_loggers
key in the :setting:LOGGING
dictConfig is set toTrue
(which is the default) the default configuration is completely overridden.
That is not right and it is pretty painful to trace down that the django.request
and django.security
, although disabled, don't propagate to the root logger even when disable_existing_loggers
in my LOGGING is True
. One would expect the disabling would allow the logger to propagate again.
Many people apparently already ran into this.
There are Stack Overflow questions and blog posts about this topic. Best of them I found is here: http://www.caktusgroup.com/blog/2015/01/27/Django-Logging-Configuration-logging_config-default-settings-logger/
It suggests the working way to put to settings
to really erase the default logging. I think it should definitely be stated in the doc.
LOGGING_CONFIG = None LOGGING = {...} # whatever you want import logging.config logging.config.dictConfig(LOGGING)
The logging system is complex by itself, something it is not a pleasure to work with for many. The reset path eliminating the confusion would be most welcome.
Attachments (1)
Change History (13)
comment:1 by , 10 years ago
Easy pickings: | unset |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 10 years ago
Attachment: | dj-doc-logging.patch added |
---|
comment:2 by , 10 years ago
Thank you. Sending a draft.
(Sorry, if the markup is wrong. ReST can compete with the logging module in opacity...)
comment:3 by , 10 years ago
There is a neat module logging_tree
by Brandon Rhodes on PyPi that can be of tremendous help during understanding of the actual logger tree.
I don't know whether it could be considered to merge the module to Django, but what if I send a patch mentionting this module in the logging.txt
doc?
comment:4 by , 10 years ago
Has patch: | set |
---|
comment:5 by , 10 years ago
I lightly edited your patch and created a pull request so others can offer their thoughts. I also posted to django-developers to see if we can improve the state of logging in Django more generally.
comment:7 by , 10 years ago
Triage Stage: | Ready for checkin → Accepted |
---|
I'll be happy to review any patch you could draft. See also #23394 and #23784.