From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 3 Feb 2026 14:55:07 +0000 (+0100) Subject: [3.14] gh-127313: Use getLogger() without argument to get root logger in logging... X-Git-Tag: v3.14.3~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=07d080a608b070c75ec1baac0d15046df8cda04a;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-127313: Use getLogger() without argument to get root logger in logging cookbook (GH-143683) (GH-144431) gh-127313: Use getLogger() without argument to get root logger in logging cookbook (GH-143683) Use getLogger() to get root logger in logging cookbook (cherry picked from commit 53fecbe6e116a4426058b7d0f6c451719c72cb5b) Co-authored-by: AN Long --- diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst index 52537a91df54..9633bc75f2c9 100644 --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -229,7 +229,7 @@ messages should not. Here's how you can achieve this:: # tell the handler to use this format console.setFormatter(formatter) # add the handler to the root logger - logging.getLogger('').addHandler(console) + logging.getLogger().addHandler(console) # Now, we can log to the root logger, or any other logger. First the root... logging.info('Jackdaws love my big sphinx of quartz.') @@ -650,7 +650,7 @@ the receiving end. A simple way of doing this is attaching a import logging, logging.handlers - rootLogger = logging.getLogger('') + rootLogger = logging.getLogger() rootLogger.setLevel(logging.DEBUG) socketHandler = logging.handlers.SocketHandler('localhost', logging.handlers.DEFAULT_TCP_LOGGING_PORT)