Python 3.6 Logging模块
来源:互联网 发布:人之将死其言也善 知乎 编辑:程序博客网 时间:2024/06/08 06:43
Logging是一个很方便的模块,用来打印日志
我直接列出一个最灵活的方法
import logginglogger = logging.getLogger() # logging对象fh = logging.FileHandler("test.log") # 文件对象sh = logging.StreamHandler() # 输出流对象fm = logging.Formatter('%(asctime)s-%(filename)s[line%(lineno)d]-%(levelname)s-%(message)s') # 格式化对象fh.setFormatter(fm) # 设置格式sh.setFormatter(fm) # 设置格式logger.addHandler(fh) # logger添加文件输出流logger.addHandler(sh) # logger添加标准输出流(std out)logger.setLevel(logging.DEBUG) # 设置从那个等级开始提示logger.debug("debug Test")logger.info("info Test")logger.warning("warning Test")logger.error("error Test")logger.critical("critical Test")
阅读全文
0 0
- Python 3.6 Logging模块
- python模块 ---logging模块
- python logging模块学习
- Python标准模块logging
- Python标准模块logging
- python logging模块
- python 之logging模块
- python的logging模块
- Python标准模块logging
- [python相关]logging模块
- Python标准模块logging
- python logging模块学习
- Python标准模块logging
- Python日志模块-logging
- Python模块logging
- python的logging模块
- Python标准模块logging
- Python标准模块logging
- 64位Hash算法Pascal版本
- 视频直播时连麦功能使用说明
- 图像识别与处理之Opencv——Mat_类与Mat 类的内存管理
- ios CLLocation定位坐标转换成ArcGIS坐标点
- 音视频入门
- Python 3.6 Logging模块
- linux+oracle初学
- CharsetDetector的简单用法
- ITK4.12+VS2015配置详解
- Spring MVC 中的基于注解的 Controller
- sizeof详解
- Dubbo与Zookeeper、SpringMVC部署与引入
- Spring Cloud 入门系列总结
- python assert