Web.py Cookbook 简体中文版 - 管理自带webserver日志
问题
如何操作web.py自带的webserver的日志?
解法
我们可以用wsgilog来操作内置的webserver的日志,并做其为中间件加到应用中。
如下,写一个Log类继承wsgilog.WsgiLog,在_init_中把参数传给基类,如这个例子:
import sys, logging from wsgilog import WsgiLog, LogIO import config class Log(WsgiLog): def __init__(self, application): WsgiLog.__init__( self, application, logformat = '%(message)s', tofile = True, file = config.log_file, interval = config.log_interval, backups...