Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 当我调用Logging.config.fileConfig时,日志系统多次失败_Python_Logging_Python Logging - Fatal编程技术网

Python 当我调用Logging.config.fileConfig时,日志系统多次失败

Python 当我调用Logging.config.fileConfig时,日志系统多次失败,python,logging,python-logging,Python,Logging,Python Logging,在Python 3.7.3中,如果多次调用logging.config.fileConfig,日志系统会自动失败。 是什么导致了这种情况 import logging.config logging.config.fileConfig('logging.conf') logger = logging.getLogger(__name__) logger.error("I print") logging.config.fileConfig('logging.conf') logger.error

在Python 3.7.3中,如果多次调用logging.config.fileConfig,日志系统会自动失败。
是什么导致了这种情况

import logging.config
logging.config.fileConfig('logging.conf')
logger = logging.getLogger(__name__)


logger.error("I print")
logging.config.fileConfig('logging.conf')
logger.error("I do not")
一种解决方法是将每次调用包装到
logging.config.fileConfig
callin
if\uuuuuu name\uuuuuu=='\uuuuu main\uuuuu':


有更好的方法吗?

您需要通过如下方式调用来确保不禁用任何现有记录器:

logging.config.fileConfig('logging.conf', disable_existing_loggers=False)

这是有文档记录的。

您需要确保没有通过如下方式调用来禁用任何现有记录器:

logging.config.fileConfig('logging.conf', disable_existing_loggers=False)
这是有案可查的