Skip to content

vllm.logging_utils.uvicorn_logging

Uvicorn logging configuration and access log filtering.

Classes:

Functions:

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.

filter(record)

Determine if the log record should be logged.

Parameters:

  • record

    (LogRecord) –

    The log record to evaluate.

Returns:

  • bool –

    True if the record should be logged, False otherwise.

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)