https://github.com/python/cpython/commit/ad5bd4ad47944f470896aa05f352f1e9118f30e7
commit: ad5bd4ad47944f470896aa05f352f1e9118f30e7
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: encukou <[email protected]>
date: 2026-02-03T14:55:25Z
summary:

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

Co-authored-by: AN Long <[email protected]>

files:
M Doc/howto/logging-cookbook.rst

diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst
index c53be94a74009d..cb51f52375a19f 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.')
@@ -637,7 +637,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)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to