import logging from tornado.web import StaticFileHandler, HTTPError class QuietStaticFileHandler(StaticFileHandler): """Minor override of logging in StaticFileHandler to log HTTP errors at debug level instead of their usual warning level. Without this, attacks on Spothole which try to do path traversal attacks would log exceptions from inside Tornado, and the server logs would contain a lot of this type of content. This effectively changes the log level of these exceptions to DEBUG so they are only logged if DEBUG level logging is enabled.""" def log_exception(self, typ, value, tb): if isinstance(value, HTTPError): logging.debug(value) return super().log_exception(typ, value, tb)