首页 > 代码库 > python打log

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))

 

python打log