转: http://www.jianshu.com/p/feb86c06c4f4
默认情况下,logging模块将日志打印到屏幕上(stdout),日志级别为WARNING(即只有日志级别高于WARNING的日志信息才会输出),日志格式如下图所示:
1 2 3 4 5 6 7 8 9 10 11 12 |
#!/usr/local/bin/python # -*- coding:utf-8 -*- import logging # 通过下面的方式进行简单配置输出方式与日志级别 logging.basicConfig(filename='logger.log', level=logging.INFO) logging.debug('debug message') logging.info('info message') logging.warn('warn message') logging.error('error message') logging.critical('critical message') |