def loggingInit(logname):
isExists = os.path.exists('../log')
if not isExists:
os.mkdir('../log')
LogExists = os.path.exists(logname)
if not LogExists:
f = open(logname, 'w')
f.close()
log = logging.getLogger(logname)
log.setLevel(logging.DEBUG)
logHandler = logging.handlers.RotatingFileHandler(logname,maxBytes=10*1024*1024,backupCount=5)
logHandler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
logHandler.setFormatter(formatter)
log.addHandler(logHandler)
return log
评论列表
文章目录