python的logging.config使用详解
来源:互联网 发布:大二层和三层网络区别 编辑:程序博客网 时间:2024/06/05 02:34
python的log模块是日常使用最多的模块之一, 简单的使用这里就不多说了,见(http://blog.csdn.net/jianhong1990/article/details/17475717)。
实际运用中,我们可能需要将日志的配置信息独立出来,这时候我们就需要用到logging的另一个功能:
test.py
# test.pyimport loggingimport logging.configlogging.config.fileConfig("logging.conf")#create loggerlogger = logging.getLogger("example")#"application" codelogger.debug("debug message")logger.info("info message")logger.warn("warn message")logger.error("error message")logger.critical("critical message")logHello = logging.getLogger("hello")logHello.info("Hello world!")
logging.conf配置文件:
[loggers]keys=root,example[handlers]keys=consoleHandler,rotateFileHandler,rootFileHandler[formatters]keys=simpleFormatter[formatter_simpleFormatter]format=[%(asctime)s](%(levelname)s)%(name)s : %(message)s[logger_root]level=DEBUGhandlers=consoleHandler,rootFileHandler[logger_example]level=DEBUGhandlers=consoleHandler,rotateFileHandler#在app中应用这个log的名字qualname=example#是否会传递到更高级的logger中,类似于冒泡,会传递到父logger中propagate=0[handler_consoleHandler]class=StreamHandlerlevel=DEBUGformatter=simpleFormatterargs=(sys.stdout,)[handler_rotateFileHandler]class=handlers.RotatingFileHandlerlevel=DEBUGformatter=simpleFormatterargs=('logs/cdnlog/test.log', 'a', 200000, 9)[handler_rootFileHandler]class=handlers.RotatingFileHandlerlevel=DEBUGformatter=simpleFormatterargs=('logs/cdnlog/root.log', 'a', 200000, 9)
- python的logging.config使用详解
- 使用Python的logging.config
- 使用Python的logging.config
- python的logging使用
- Python的logging使用
- python logging的使用
- python-logging.config【日志模块】
- 使用python的logging模块
- 使用python的logging模块
- 使用python的logging模块
- 【python系列】logging的使用
- 使用python的logging模块
- 使用python的logging模块
- 使用python的logging模块
- 使用python的logging模块
- Python的Logging使用教程
- 使用python的logging模块
- 【python】logging模块的使用
- HDu2680(Choose the best route)
- VB制作BHO写下载器或病毒会用到
- Android中HTTP请求出现“Received authentication challenge is null”异常和“Read timed out”解决
- key_t IPC键和ftok函数详解和剖析
- 使用SQLServer2005的链接服务器链接Sybase数据库
- python的logging.config使用详解
- PJSUA命令行分析
- ubuntu的终端无法输入字母A
- 关于Segmentation fault (core dumped)几个简单问题
- linux网络配置
- response和request的setCharacterEncoding .
- php string 函数
- 用vim做php开发配置备忘,适合稍有vim经验的php程序员
- 排序----归并排序