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

Vinay Sajip report at bugs.python.org
Thu Sep 2 14:59:52 EDT 2021


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

Thanks, but ...

> I observe that many Python users tend to use basicConfig() even when they would be better served by configuring only the logger(s) needed for their own app/library.

First of all, library developers should not be configuring loggers at all, other than adding a NullHandler to their top-level logger.

Secondly, it is fine to configure the root logger and then log to any other logger. The default mechanisms mean that handlers added to the root logger are used by loggers which are anywhere in the logger hierarchy. So users that are using basicConfig() but other loggers than the root logger may be using the system as designed.

Thirdly, logging.config.dictConfig() allows usage of a dictionary to configure multiple loggers, handlers etc. all at once, for use cases which are more demanding than basicConfig(). It doesn't make sense to do what you're proposing, since it appears to offer a different way of configuring other loggers than the root logger, when dictConfig() already offers that.

So, I am minded to not agree to this change, and would prefer that the PR and this issue be closed.

----------
nosy: +vinay.sajip

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


More information about the Python-bugs-list mailing list