[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 53fecbe6e1)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2026-02-03 15:55:07 +01:00 committed by GitHub
parent eb0790f2d7
commit 07d080a608
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)