import logging
import time
logger = logging.getLogger()
logger.setLevel(logging.INFO)
rq = time.strftime(u'%Y%m%d%H%M', time.localtime(time.time()))
log_path = u'C:/Users/ysten/Desktop/celery_beat/Logs'
log_name = log_path + rq + u'.log'
logfile = log_name
fh = logging.FileHandler(logfile, mode=u'a')
fh.setLevel(logging.INFO) # 输出到file的log等级的开关
formatter = logging.Formatter(u"%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s")
fh.setFormatter(formatter)
logger.addHandler(fh)
# 哪里需要直接导入过去即可使用
logger.info("xxxxxxx")