python logging.getlogger_python的问题日志记录.getLogger(姓名)

如果您想为库的记录器自定义日志处理程序,只需在

1)上层记录器(例如根记录器)。{a1}作为参考}rootLogger = logging.getLogger('')

rootLogger.setLevel(logging.DEBUG)

socketHandler = logging.handlers.SocketHandler('localhost',

logging.handlers.DEFAULT_TCP_LOGGING_PORT)

# don't bother with a formatter, since a socket handler sends the event as

# an unformatted pickle

rootLogger.addHandler(socketHandler)

# Now, we can log to the root logger, or any other logger. First the root...

logging.info('Jackdaws love my big sphinx of quartz.')

# Now, define a couple of other loggers which might represent areas in your

# application:

logger1 = logging.getLogger('myapp.area1')

logger2 = logging.getLogger('myapp.area2')

2)或捕获库的记录器并显式配置

^{pr2}$

你可能感兴趣的:(python)