python logging类库中RotatingFileHandler的使用
2017-05-23 16:51
543 查看
日志级别大小关系为:CRITICAL > ERROR > WARNING > INFO > DEBUG > NOTSET,当然也可以自己定义日志级别。
日志回滚的意思为:比如日志文件是chat.log,当chat.log达到指定的大小之后,RotatingFileHandler自动把文件改名为chat.log.1。不过,如果chat.log.1已经存在,会先把chat.log.1重命名为chat.log.2。最后重新创建 chat.log,继续输出日志信息。【这样保证了chat.log里面是最新的日志】
遇到的一个问题:
结果:
从结果中可看出debug和info级别的信息没有打印出来;
代码修改后:
结果:
日志回滚的意思为:比如日志文件是chat.log,当chat.log达到指定的大小之后,RotatingFileHandler自动把文件改名为chat.log.1。不过,如果chat.log.1已经存在,会先把chat.log.1重命名为chat.log.2。最后重新创建 chat.log,继续输出日志信息。【这样保证了chat.log里面是最新的日志】
遇到的一个问题:
结果:
从结果中可看出debug和info级别的信息没有打印出来;
代码修改后:
结果:
相关文章推荐
- python logging现学现用 – TimedRotatingFileHandler使用方法
- Python logging RotatingFileHandler bug
- python logging 模块之TimedRotatingFileHandler 实现每天一个日志文件
- Python多进程不要使用TimedRotatingFileHandler
- Python logging RotatingFileHandler bug
- [bigdata-078] python3 logging 的示例 TimedRotatingFileHandler和RotatingFileHandler 基于时间切分和基于文件大小切分
- python logging类库使用例子
- logging TimedRotatingFileHandler不支持多进程
- Python的RotatingFileHandler的Bug
- python日志按时间切分-----TimedRotatingFileHandler
- python logging类库使用例子
- 使用FileReference+HttpHandler实现文件上传/下载(Flex与.NET互操作)
- python类库31[使用SAX来解析xml]
- [Python学习] Logging模块的简单使用
- 经常使用的一个python logging封装,支持同时向console和文件输出
- python类库32[多进程之Pool+Logging]
- python类库31[使用minidom读写xml]
- python中os.path.dirname(__file__)的使用
- apache+python中对logging模块的使用问题
- python类库31[使用xml.etree.ElementTree读写xml]