import os import logging from logging.handlers import RotatingFileHandler import platform platform_ = platform.system() is_win = is_linux = is_mac = False if platform_ == "Windows": is_win = True elif platform_ == "Linux": is_linux = True elif platform_ == "Mac": is_mac = True def init_logging(log_file_path=None, file_name=‘out.log‘): path = log_file_path if not os.path.exists(path): os.makedirs(path) logging.basicConfig( handlers=[RotatingFileHandler(path + file_name,
# 设置 日子文件大小100M 超过自动换文件 maxBytes=100 * 1024 * 1024, backupCount=5, encoding=‘utf-8‘, delay=0), logging.StreamHandler()], level=logging.INFO, format=‘%(asctime)s.%(msecs)03d %(thread)d %(levelname)s %(module)s %(lineno)d - %(funcName)s : %(message)s‘, datefmt="%Y-%m-%d %H:%M:%S")
原文:https://www.cnblogs.com/bianzhiwei/p/10826090.html