[issue45027] Allow basicConfig to configure any logger, not just root

Vinay Sajip report at bugs.python.org
Thu Sep 16 09:18:33 EDT 2021


Vinay Sajip <vinay_sajip at yahoo.co.uk> added the comment:

> This change serves the purpose of making it easier to configure non-root loggers.

My point was, they don't need to configure non-root loggers (in terms of adding handlers) because the root logger's handlers will normally be used for all loggers.

> However, if you configure the root logger in your application, you will see those [other libraries'] log messages.

Users certainly don't need an API change to prevent that, should they wish to. The following simple call will suffice (using 'gnupg' just as an example):

logging.getLogger('gnupg').setLevel(logging.CRITICAL + 1)

> I would frame this proposal as a third configuration option

As you can see, it's not needed for the purpose you described (avoiding messages from third-party loggers).

> it would be nice to adjust the type stubs for dictConfig() to use a TypedDict ... I'm happy to make a PR to Typeshed for it, though!

Sure, sounds like a good idea.

> I also think there should be a note about dictConfig() in the docs for basicConfig() ... Again, I'm happy to make a separate PR for that change.

By all means. You could also look at updating the cookbook content, if you feel that parts relating to the concerns expressed in this issue could be expanded on.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45027>
_______________________________________


More information about the Python-bugs-list mailing list