设置日志即控制台输出又文本输出
## 注意longging.FileHandler和logging.StreamHandler
import logging
import datetime,time
import sys
import pdb
logger = logging.getLogger('mylogger')
logger.setLevel(logging.DEBUG)#总的级别入口
time_style = time.strftime('%Y-%m-%d', time.localtime(time.time()))
print(time_style)
f_handler = logging.FileHandler(filename='mylog',mode='a')#设置输出方式
f_handler.setLevel(logging.INFO)#设置输出的级别
f_handler.setFormatter(logging.Formatter("%(asctime)s-%(name)s-%(message)s"))
sf_handler=logging.StreamHandler(sys.stderr)
sf_handler.setFormatter(logging.Formatter(fmt="%(asctime)s-%(name)s-%(message)s",datefmt=time_style))
sf_handler.setLevel(logging.INFO)
gf_handler=logging.FileHandler(filename='mylog2')
gf_handler.setLevel(logging.INFO)
gf_handler.setFormatter(time_style)
logger.addHandler(gf_handler)
logger.addHandler(f_handler)
logger.addHandler(sf_handler)
logger.debug('debug message')
logger.info('info message')
logger.warning('warning message')
logger.error('error message')
logger.critical('critical message')