def make_rotate_logs(self, app):
# see http://www.cherrypy.org/wiki/Logging#CustomHandlers
log = app.log
# Remove the default FileHandlers if present.
log.error_file = ""
log.access_file = ""
maxbytes = getattr(log, "rot_maxBytes", 10485760)
backupcount = getattr(log, "rot_backupCount", 5)
# Make a new RotatingFileHandler for the error log.
fname = getattr(log, "rot_error_file", "error.log")
h = handlers.RotatingFileHandler(fname, 'a', maxbytes, backupcount)
h.setLevel(logging.DEBUG)
h.setFormatter(_cplogging.logfmt)
log.error_log.addHandler(h)
# Make a new RotatingFileHandler for the access log.
fname = getattr(log, "rot_access_file", "access.log")
h = handlers.RotatingFileHandler(fname, 'a', maxbytes, backupcount)
h.setLevel(logging.DEBUG)
h.setFormatter(_cplogging.logfmt)
log.access_log.addHandler(h)
评论列表
文章目录