简体   繁体   中英

Change endpoint logging behavior in Tornado

I'm using Tornado 5 to run a site with several endpoints. One of those endpoints is just for health checks and I really don't need that particular endpoint showing up in the logs every 2 seconds as a simple GET request.

Is there any way to disable logging for that single endpoint, or at least switch it to maybe a DEBUG log message rather than logging as INFO?

Thanks for any assistance

You can override the RequestHandler._log method:

https://github.com/tornadoweb/tornado/blob/fc6dd2345c3c8af0186765fc0396ff70e47c3022/tornado/web.py#L1725

Or for a more complex but arguably cleaner way, you can pass a log_function to your Application that inspects the handler and is a no-op for your health check handler.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM