python日志开启
来源:互联网 发布:linux语言改为中文 编辑:程序博客网 时间:2024/04/29 18:30
import logging# 设置默认的level为DEBUG# 设置log的格式logging.basicConfig( level=logging.DEBUG, format="[%(asctime)s] %(name)s:%(levelname)s: %(message)s")# 记录loglogging.debug(...)logging.info(...)logging.warn(...)logging.error(...)logging.critical(...)
上面的代码中,如果将level=logging.DEBUG这一行的日志打印级别调高,则源码中只有满足对应级别的调试信息才会打印出来。如下所示test.py:
import logginglogging.basicConfig( level = logging.DEBUG, format = "[%(asctime)s] %(name)s:%(levelname)s: %(message)s")if __name__ == '__main__': logging.debug('hello word - debug') logging.info('hello word - info') logging.warn('hello word - warn') logging.error('hello word - error') logging.critical('hello word - critical')
倘若将logging级别更改为INFO,则只会打印INFO以上级别的信息
0 0
- python日志开启
- 开启Python
- 开启mysql日志
- Mysql开启日志
- 开启MYSQL日志配置
- Mysql开启日志
- mysql 开启日志方法
- MYSQL开启日志
- ubnuntu cron开启日志
- 开启mysql操作日志
- MySQL开启binlog日志
- mysql开启日志功能
- MySQL开启二进制日志
- Raspberry - 开启crontab日志
- mysql开启sql日志
- ubuntu crontab开启日志
- mysql开启慢日志
- mysql开启日志功能
- SSM三大框架整合详细教程(Spring+SpringMVC+MyBatis)
- android插入耳机状态使用扬声器外放音乐
- 换行符和回车符
- 给你的应用设置系统签名
- 用户空间和内核空间通讯之【Netlink 上】
- python日志开启
- DB2 常用命令之 重命名数据 表
- PostgreSQL numeric类型上的算术运算比整数类型或者浮点数类型要慢很多
- hibernate 中fetch配置
- Linux修改主机名
- 视频清晰度、色偏以及亮度异常检测
- 用户空间和内核空间通讯之【Netlink 中】
- PHP_保留两位小数并且四舍五入_保留两位小数并且不四舍五入_取整
- 用户空间和内核空间通讯之【Netlink 下】