python 的一个日志器备忘
logger = logging.getLogger("%s_name"%__name__) logger.setLevel(logging.DEBUG) fh = logging.FileHandler('RuiNeng.log','a+',encoding='utf-8') fh.setLevel(logging.DEBUG) stream = logging.StreamHandler() stream.setLevel(logging.DEBUG) format=logging.Formatter('%(asctime)s-%(levelname)s-%(message)s') fh.setFormatter(format) stream.setFormatter(format) logger.addHandler(fh) logger.addHandler(stream)