Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#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 to True (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)

dj-doc-logging.patch (2.9 KB ) - added by Vlada Macek 10 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 by Tim Graham, 10 years ago

Easy pickings: unset
Triage Stage: UnreviewedAccepted

I'll be happy to review any patch you could draft. See also #23394 and #23784.

by Vlada Macek, 10 years ago

Attachment: dj-doc-logging.patch added

comment:2 by Vlada Macek, 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 Vlada Macek, 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 Tim Graham, 10 years ago

Has patch: set

comment:5 by Tim Graham, 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:6 by Paul Hallett, 10 years ago

Triage Stage: AcceptedReady for checkin

Looks good and makes sense.

comment:7 by Tim Graham, 10 years ago

Triage Stage: Ready for checkinAccepted

comment:8 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In c633667d:

Fixed #24361 -- Clarified docs on reconfiguring logging.

Thanks Tuttle for the report and draft patch, and Carl Meyer for
help and review.

comment:9 by Tim Graham <timograham@…>, 10 years ago

In 0dc986d1:

[1.8.x] Fixed #24361 -- Clarified docs on reconfiguring logging.

Thanks Tuttle for the report and draft patch, and Carl Meyer for
help and review.

Backport of c633667da3605208ea5fc137f5322c599f48da69 from master

comment:10 by Tim Graham <timograham@…>, 10 years ago

In 0121fb81:

[1.7.x] Fixed #24361 -- Clarified docs on reconfiguring logging.

Thanks Tuttle for the report and draft patch, and Carl Meyer for
help and review.

Backport of c633667da3605208ea5fc137f5322c599f48da69 from master

comment:11 by Tim Graham <timograham@…>, 9 years ago

In 4a06a90:

Refs #24361 -- Corrected documented level of the 'django' logger.

The logger doesn't define an explicit level, therefore it defaults
to WARNING.

comment:12 by Tim Graham <timograham@…>, 9 years ago

In 8f42934f:

[1.7.x] Refs #24361 -- Corrected documented level of the 'django' logger.

The logger doesn't define an explicit level, therefore it defaults
to WARNING.

Backport of 4a06a904dcd27388ec9a3cfb2bc8a8421bb44816 from stable/1.8.x

Note: See TracTickets for help on using tickets.
Back to Top