How to log requests to stdout in Tornado web server?

前端 未结 3 699
南方客
南方客 2021-02-19 00:44

I\'m starting to develop a simple Tornado application, and I\'d like to see request log in stdout while I develop. Currently I only see 404 warning messages.

Is there a

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-19 00:59

    Why don't you print? Use print self.request somewhere inside the request handler (maybe inside the prepare method).

    Or better:

    class BaseHandler(tornado.web.RequestHandler):
        def prepare(self):
            print self.request
    
    class SomeHandler(BaseHandler):
        ...
    

    use a base class for your request handlers and subclass it from that time on.

提交回复
热议问题