Skip to content

Commit d2739ec

Browse files
committed
Use getLogger() to get root logger in logging cookbook
1 parent f5e11fa commit d2739ec

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.')
@@ -650,7 +650,7 @@ the receiving end. A simple way of doing this is attaching a
650650

651651
import logging, logging.handlers
652652

653-
rootLogger = logging.getLogger('')
653+
rootLogger = logging.getLogger()
654654
rootLogger.setLevel(logging.DEBUG)
655655
socketHandler = logging.handlers.SocketHandler('localhost',
656656
logging.handlers.DEFAULT_TCP_LOGGING_PORT)

0 commit comments

Comments
 (0)