vllm.logging_utils.uvicorn_logging
¶
Uvicorn logging configuration and access log filtering.
Classes:
-
UvicornAccessLogFilter–A logging filter that excludes access logs for specified endpoint paths.
Functions:
-
create_uvicorn_log_config–Create a uvicorn logging configuration with optional access filtering.
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:
-
(excluded_paths¶list[str] | None, default:None) –A list of URL paths to exclude from logging. Paths are matched exactly. Example: ["/health", "/metrics"]
Methods:
-
filter–Determine if the log record should be logged.
Source code in vllm/logging_utils/uvicorn_logging.py
filter(record)
¶
Determine if the log record should be logged.
Parameters:
Returns:
-
bool–True if the record should be logged, False otherwise.
Source code in vllm/logging_utils/uvicorn_logging.py
create_uvicorn_log_config(excluded_paths=None, log_level='info', formatter='text')
¶
Create a uvicorn logging configuration with optional access 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:
-
(excluded_paths¶list[str] | None, default:None) –List of URL paths to exclude from access logs.
-
(log_level¶str, default:'info') –The log level for uvicorn loggers.
-
(formatter¶Literal['text', 'json'], default:'text') –Format used for uvicorn logs.
Returns:
-
dict–A dictionary containing the logging configuration.
Example
config = create_uvicorn_log_config(["/health", "/metrics"]) uvicorn.run(app, log_config=config)
Source code in vllm/logging_utils/uvicorn_logging.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |