Created
August 26, 2021 05:44
-
-
Save DFilyushin/7862b27cb0afc0fe8284320ed37d9eac to your computer and use it in GitHub Desktop.
Disable access log for FastAPI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EndpointFilter(logging.Filter): | |
def filter(self, record: logging.LogRecord) -> bool: | |
return record.getMessage().find("/endpoint") == -1 | |
# Filter out /endpoint | |
logging.getLogger("uvicorn.access").addFilter(EndpointFilter()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment