python - 日志没有写入文件
问题描述
我在此处使用以下示例,以及来自 Gnu/Linux 虚拟环境的 Python 3.6.5:
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
没有生成输出文件。
我注意到它适用于 Python 2.7.15。
有任何想法吗?
解决方案
推荐阅读
- c++ - 如何在 MSVC 2015 MFC 对话框中插入富编辑控件
- linux - 如何等待进程写入文件或退出?
- laravel - 当我遇到这种情况时,如何从控制器中先前设置的雄辩关系(用户模型)中急切加载“用户”功能
- r - R - 从 data.frame 中删除行
- c++ - 成员分配过载时的堆损坏?
- aws-iot - AWS Greengrass 不生成用户日志
- html - 简单搜索字段在每个浏览器中的处理方式都不同
- metpy - 如何在metpy中将文本框添加到skew-t图中?
- java - 带有 MessagePack 的 Apache Beam - 如何从 Map 获取值
? - kubernetes - kubectl top 是当前内存/CPU 值吗?