我正在尝试为Python配置一些日志记录。从 http://docs.python.org/howto/logging.html 建议使用YAML配置文件-
version: 1
formatters:
simple:
format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
handlers:
console:
class: logging.StreamHandler
level: DEBUG
formatter: simple
stream: ext://sys.stdout
loggers:
simpleExample:
level: DEBUG
handlers: [console]
propagate: no
root:
level: DEBUG
handlers: [console]
在我的代码中,我用这个作为-
^{pr2}$但是,运行它时,我得到一个错误
Traceback (most recent call last):
File "TestLogger.py", line 62, in <module>
Test5()
File "TestLogger.py", line 55, in Test5
logging.config.dictConfig('logging.dict.2.config')
File "/usr/lib/python2.7/logging/config.py", line 776, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib/python2.7/logging/config.py", line 380, in __init__
self.config = ConvertingDict(config)
ValueError: dictionary update sequence element #0 has length 1; 2 is required
所以我似乎调用配置文件的方式不正确。只是找不到正确的方法来调用它。请帮忙? 非常感谢
您需要加载并解析YAML文件:
相关问题 更多 >
编程相关推荐