【发布时间】:2013-06-26 12:25:30
【问题描述】:
我注意到我无法从终端登录到 ipython 下的文件。
如果我从控制台运行以下代码,则会创建文件 aaa.log,但当我从 ipython qtconsole 运行它时不会创建。 (我用python 3.2.3 ipython: 0.13.1)
我的怀疑是 ipython 自己的日志记录功能妨碍了。有没有办法也可以在 ipython 中使用这种“标准”日志记录?然而,将日志消息输出到 qtconsole 似乎可行。
import logging
logging.basicConfig(filename='aaa.log', filemode='w', level=logging.DEBUG)
def my_method():
logging.debug('This message should go to the log file 2')
logging.info('So should this')
logging.warning('And this, too')
if __name__=='__main__':
my_method()
【问题讨论】:
-
我在这里找到了我的问题的答案:stackoverflow.com/questions/5691130/…