Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc44b81

Browse files
authored
[doc] Add a note in howto/logging.rst about "do not log to root logger in libraries" (GH-31271)
1 parent 0d9b565 commit fc44b81

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Doc/howto/logging.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,13 @@ should have the desired effect. If an organisation produces a number of
831831
libraries, then the logger name specified can be 'orgname.foo' rather than
832832
just 'foo'.
833833

834+
.. note:: It is strongly advised that you *do not log to the root logger*
835+
in your library. Instead, use a logger with a unique and easily
836+
identifiable name, such as the ``__name__`` for your library's top-level package
837+
or module. Logging to the root logger will make it difficult or impossible for
838+
the application developer to configure the logging verbosity or handlers of
839+
your library as they wish.
840+
834841
.. note:: It is strongly advised that you *do not add any handlers other
835842
than* :class:`~logging.NullHandler` *to your library's loggers*. This is
836843
because the configuration of handlers is the prerogative of the application

0 commit comments

Comments
 (0)