python log

import logging.handlers
import logging
import shelve
import time


def loggers(logname):
    logger = logging.getLogger(logname)
    logger.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(name)-12s %(asctime)s %(levelname)-8s %(message)s', '%a, %d %b %Y %H:%M:%S',)
    file_handle = logging.FileHandler(logname)
    file_handle.setFormatter(formatter)
    #handler = logging.handlers.RotatingFileHandler('anay.log',maxBytes=20000000,backupCount=500000)
    #logger.addHandler(handler)
    logger.addHandler(file_handle)
    return logger

你可能感兴趣的:(python log)