概述
In [1]: import logging ...: logging.basicConfig(filename='example.log',level=logging.DEBUG) ...: logging.debug('This message should go to the log file') ...: logging.info('So should this') ...: logging.warning('And this,too') WARNING:root:And this,too In [2]: ls example.log File not found
有人可以帮助我了解我做错了什么吗?谢谢…
编辑:将第二次输入后的输出改为英文,并删除不必要的部分.唯一重要的是Python不会创建文件example.log.
This function does nothing if the root logger already has handlers
configured for it.
你所得到的只是Python是这样的:
C:\temp>python ActivePython 2.6.1.1 (ActiveState Software Inc.) based on Python 2.6.1 (r261:67515,Dec 5 2008,13:58:38) [MSC v.1500 32 bit (Intel)] on win32 Type "help","copyright","credits" or "license" for more information. >>> import logging >>> logging.basicConfig(filename='example.log',level=logging.DEBUG) >>> logging.debug('This message should go to the log file') >>> logging.info('And so should this') >>> logging.warning('And this,too') >>> ^Z C:\temp>type example.log DEBUG:root:This message should go to the log file INFO:root:And so should this WARNING:root:And this,too
总结
以上是编程之家为你收集整理的Python不创建日志文件全部内容,希望文章能够帮你解决Python不创建日志文件所遇到的程序开发问题。
如果您也喜欢它,动动您的小指点个赞吧