I have my own logging system that is not based on a logging object. Can I still enjoy the services of RotatingFileHnadler ? I've tried to define the handler after I set the log file. But I don't see it performed any rotation (no files added named for example mylog.log.1, mylog.log.2 ...) What am I missing?
handler = RotatingFileHandler(self.fullName+'.debug',mode='a', maxBytes=1, backupCount=1)
logFormatter = logging.Formatter("%(asctime)s [%(levelname)-5.5s] %(message)s")
fileHandler = RotatingFileHandler('/var/log/blabla.log',
maxBytes=10 * 1000 * 1000,
encoding='utf8',
backupCount=5)
fileHandler.setFormatter(logFormatter)
rootLogger = logging.getLogger()
rootLogger.setLevel(logging.INFO)
rootLogger.addHandler(fileHandler)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.