diff --git a/sanic/static.py b/sanic/static.py index c9c29fba..0a75d9dc 100644 --- a/sanic/static.py +++ b/sanic/static.py @@ -13,6 +13,7 @@ from sanic.exceptions import ( InvalidUsage, ) from sanic.handlers import ContentRangeHandler +from sanic.log import error_logger from sanic.response import HTTPResponse, file, file_stream @@ -40,6 +41,10 @@ async def _static_request_handler( # match filenames which got encoded (filenames with spaces etc) file_path = path.abspath(unquote(file_path)) if not file_path.startswith(path.abspath(unquote(root_path))): + error_logger.exception( + f"File not found: path={file_or_directory}, " + f"relative_url={file_uri}" + ) raise FileNotFound( "File not found", path=file_or_directory, relative_url=file_uri ) @@ -94,6 +99,10 @@ async def _static_request_handler( except ContentRangeError: raise except Exception: + error_logger.exception( + f"File not found: path={file_or_directory}, " + f"relative_url={file_uri}" + ) raise FileNotFound( "File not found", path=file_or_directory, relative_url=file_uri )