我现在正在使用ipython登录
In [1]: import logging
In [2]: logging.basicConfig(level=logging.INFO, format="%(astime)s-%(levelanme)s %(message)s")
尝试过logging.info
In [3]: logging.info("info")
--- Logging error ---
Traceback (most recent call last):
...
KeyError: 'astime'
Call stack:
....
logging.info("info")
Message: 'info'
Arguments: ()
然后我发现错字astime应该是asctime并进行更正
In [4]: logging.basicConfig(level=logging.INFO, format="%(asctime)s-%(levelanme)s %(message)s")
但是,错误仍然存在
In [5]: logging.info("info")
--- Logging error ---
... KeyError:“ astime” 调用堆栈: .... logging.info(“ info”) 讯息:“ info” 参数:()
然后我删除日志记录模块以进行另一项测试
In [16]: import logging
In [17]: del logging
In [18]: logging
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-18-723e91d57e56> in <module>
----> 1 logging
NameError: name 'logging' is not defined
In [19]: import logging
In [20]: logging.info("info")
--- Logging error ---
KeyError: 'astime'
Call stack:
logging.info("info")
Message: 'info'
Arguments: ()
“时间”仍然存在。
如何在ipython当前会话中更新日志记录配置?