python打log

 1 import logging
 2 
 3 
 4 logger = logging.getLogger('fib')
 5 logger.setLevel(logging.DEBUG)
 6 
 7 hdr = logging.StreamHandler()
 8 formatter = logging.Formatter('[%(asctime)s] %(name)s:%(levelname)s: %(message)s')
 9 hdr.setFormatter(formatter)
10 
11 logger.addHandler(hdr)
12 
13 
14 logger.debug('slq = %s' % (sql))

 

posted @ 2017-08-11 19:58  一罐热茶  阅读(200)  评论(0编辑  收藏  举报