Python KeyError:';args';使用日志文件配置时
我在尝试使用配置文件进行日志记录时遇到了一个错误。当我实现这个脚本时,我正在使用Python3.8开发一个anaconda env,它工作得很好。当我试图在根anaconda env中使用Python3.6的另一台PC上运行脚本时,它引发了以下关键错误,但在使用Python3.6的同一台PC上,但在另一个env中,它此时没有堆栈 如何使用Python KeyError:';args';使用日志文件配置时,python,logging,anaconda,config,Python,Logging,Anaconda,Config,我在尝试使用配置文件进行日志记录时遇到了一个错误。当我实现这个脚本时,我正在使用Python3.8开发一个anaconda env,它工作得很好。当我试图在根anaconda env中使用Python3.6的另一台PC上运行脚本时,它引发了以下关键错误,但在使用Python3.6的同一台PC上,但在另一个env中,它此时没有堆栈 如何使用fileConfig: current_dir=os.path.dirname(os.path.abspath(u文件_u)) filename=os.path
fileConfig
:
current_dir=os.path.dirname(os.path.abspath(u文件_u))
filename=os.path.join(当前目录'logging.conf')
logging.config.fileConfig(文件名,disable\u existing\u loggers=False)
logger=logging.getLogger(_名称__)
错误消息:
in <module> logging.config.fileConfig(filename, disable_existing_loggers=False)
File "path\to\Anaconda3\lib\logging\config.py", line 84, in fileConfig
handlers = _install_handlers(cp, formatters)
File "path\to\Anaconda3\lib\logging\config.py", line 146, in _install_handlers
args = section["args"]
File "path\to\Anaconda3\lib\configparser.py", line 1233, in __getitem__
raise KeyError(key)
KeyError: 'args'
[loggers]
keys=root
[handlers]
keys=consoleHandler
[formatters]
keys=simpleFormatter
[logger_root]
level=DEBUG
handlers=consoleHandler
[handler_consoleHandler]
class=StreamHandler
level=INFO
formatter=simpleFormatter
[formatter_simpleFormatter]
format=%(asctime)s | %(levelname)s | module: %(module)s | %(name)s -- %(message)s