我想记录stdout和stderr来记录文件,这就是我尝试过的方法。app = Flask(__name__)app.logger.setLevel(logging.INFO) # use the native logger of flaskapp.logger.disabled = Falsehandler = logging.handlers.RotatingFileHandler( SYSTEM_LOG_FILENAME, 'a', maxBytes=1024 * 1024 * 100, backupCount=20 )formatter = logging.Formatter(\ "%(asctime)s - %(levelname)s - %(name)s: \t%(message)s")handler.setFormatter(formatter)app.logger.addHandler(handler)@app.route('/')def hello(): return 'Hello World'if __name__ == '__main__': app.run() 然后,我想将控制台输出记录在文件中。如* Running on http://127.0.0.1:5000/127.0.0.1 - - [24/May/2013 14:55:14] "GET / HTTP/1.1" 200 -127.0.0.1 - - [24/May/2013 14:55:14] "GET /favicon.ico HTTP/1.1" 404 -我能做些什么?
添加回答
举报
0/150
提交
取消