Search code examples
pythontornado

Python tornado handler warnings disabling


I was define head method in tornado handler to check file exists:

def head(self, path):
    if file_isset(path):
        self.set_status(200)
    else:
        self.set_status(404)

But tornado writes message such as WARNING:tornado.access:404 HEAD /file_name to terminal. How to disable this message?


Solution

  • You can disable the logger tornado.access prior the start of the IOLoop using logging.getLogger('tornado.access').disabled = True.

    For example:

    def main():
        logging.getLogger('tornado.access').disabled = True
        app = Application()
        http_server = HTTPServer(app)
        http_server.listen(options.port, address=options.host)
        IOLoop.instance().start()