vllm.logging_utils.access_log_filter ¶
Access log filter for uvicorn to exclude specific endpoints from logging.
This module provides a logging filter that can be used to suppress access logs for specific endpoints (e.g., /health, /metrics) to reduce log noise in production environments.
UvicornAccessLogFilter ¶
Bases: Filter
A logging filter that excludes access logs for specified endpoint paths.
This filter is designed to work with uvicorn's access logger. It checks the log record's arguments for the request path and filters out records matching the excluded paths.
Uvicorn access log format
'%s - "%s %s HTTP/%s" %d' (client_addr, method, path, http_version, status_code)
Example
127.0.0.1:12345 - "GET /health HTTP/1.1" 200
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
excluded_paths | list[str] | None | A list of URL paths to exclude from logging. Paths are matched exactly. Example: ["/health", "/metrics"] | None |
Source code in vllm/logging_utils/access_log_filter.py
__init__ ¶
filter ¶
Determine if the log record should be logged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record | LogRecord | The log record to evaluate. | required |
Returns:
| Type | Description |
|---|---|
bool | True if the record should be logged, False otherwise. |
Source code in vllm/logging_utils/access_log_filter.py
create_uvicorn_log_config ¶
create_uvicorn_log_config(
excluded_paths: list[str] | None = None,
log_level: str = "info",
) -> dict
Create a uvicorn logging configuration with access log filtering.
This function generates a logging configuration dictionary that can be passed to uvicorn's log_config parameter. It sets up the access log filter to exclude specified paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
excluded_paths | list[str] | None | List of URL paths to exclude from access logs. | None |
log_level | str | The log level for uvicorn loggers. | 'info' |
Returns:
| Type | Description |
|---|---|
dict | A dictionary containing the logging configuration. |
Example
config = create_uvicorn_log_config(["/health", "/metrics"]) uvicorn.run(app, log_config=config)