I played around with this a bit, and it seems that if you
`disable_existing_loggers` but mention a specific pre-existing logger in
your new config, that logger (and its children) are not disabled. So in
your example here, because you're including the 'django' logger in your
new config, it and its children are not silenced. But the blog post is
correct that any existing loggers which aren't mentioned in the new
config are silenced, and anything logged to them doesn't propagate anymore.

For reference, here's the test script I used to experiment:
https://gist.github.com/carljm/6bd0b1b87590b1429ce7

Even mentioning a logger but not providing any config for it (as shown
in the gist) is apparently enough to preserve it from being disabled.
But if you remove mention of the `foo` logger from the `new` dict,
anything logged to `foo` or any of its children thereafter will silently
disappear.

I think this is interesting and good to know, but it doesn't change the
conclusion that we should avoid `disable_existing_loggers`.

It means that we _could_ provide a working "send all Django's logs to
stdout" example config without the LOGGING_CONFIG=None workaround. But
we still can't provide a working "send all logs to stdout" without
either that or another way to bypass Django's default logging config.

And it still seems to me that it's bad for Django's default config to
set `level: ERROR` and `propagate: False` on the django.request and
django.security loggers, as that prevents those logs from propagating to
higher-level handlers someone may want to install.

Carl

On 03/23/2015 05:07 PM, Tim Graham wrote:
> Hm, now I wonder if that blog post in my initial post is entirely
> correct. This config seems to send all Django logging to stdout
> (regardless of the value of disable_existing_loggers). The difference
> from the initially proposed doc patch is that this config redefines the
> 'django' logger instead of the 'root' logger. Investigation to continue
> tomorrow...
> 
> LOGGING = {
>     'version': 1,
>     'disable_existing_loggers': False,
>     'handlers': {
>         'console': {
>             'class': 'logging.StreamHandler',
>         },
>     },
>     'loggers': {
>         'django': {
>             'handlers': ['console'],
>             'level': 'DEBUG',
>         },
>     }
> }
> 
> On Monday, March 23, 2015 at 5:06:39 PM UTC-4, Florian Apolloner wrote:
> 
>     On Monday, March 23, 2015 at 9:45:12 PM UTC+1, Wim Feijen wrote:
> 
>         This may sound stupid, but I actually use Logbook for logging
>         because I find it easy to use.
> 
> 
>     Why would this sound stupid? Logbook is a nice library and actually
>     worth thinking about if we start using dependencies in Django.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-developers+unsubscr...@googlegroups.com
> <mailto:django-developers+unsubscr...@googlegroups.com>.
> To post to this group, send email to django-developers@googlegroups.com
> <mailto:django-developers@googlegroups.com>.
> Visit this group at http://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/8030352a-f072-4646-8b3a-a1a2fcad1b35%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/8030352a-f072-4646-8b3a-a1a2fcad1b35%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/5510BADE.1050208%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to