Skip to content

Commit ad5bd4a

Browse files
miss-islingtonaisk
andauthored
[3.13] gh-127313: Use getLogger() without argument to get root logger in logging cookbook (GH-143683) (GH-144432)
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 53fecbe) Co-authored-by: AN Long <aisk@users.noreply.github.com>
1 parent 5e88899 commit ad5bd4a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Doc/howto/logging-cookbook.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ messages should not. Here's how you can achieve this::
229229
# tell the handler to use this format
230230
console.setFormatter(formatter)
231231
# add the handler to the root logger
232-
logging.getLogger('').addHandler(console)
232+
logging.getLogger().addHandler(console)
233233

234234
# Now, we can log to the root logger, or any other logger. First the root...
235235
logging.info('Jackdaws love my big sphinx of quartz.')
@@ -637,7 +637,7 @@ the receiving end. A simple way of doing this is attaching a
637637

638638
import logging, logging.handlers
639639

640-
rootLogger = logging.getLogger('')
640+
rootLogger = logging.getLogger()
641641
rootLogger.setLevel(logging.DEBUG)
642642
socketHandler = logging.handlers.SocketHandler('localhost',
643643
logging.handlers.DEFAULT_TCP_LOGGING_PORT)

0 commit comments

Comments
 (0)