main
py 50 lines 1.83 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 from typing import Literal, cast
5
6 from pydantic import Field
7
8 import vllm.envs as envs
9 from vllm.config.utils import config
10
11 LogLevel = Literal["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "NOTSET"]
12 LogFormatter = Literal["text", "json"]
13
14
15 @config
16 class LoggingConfig:
17 """vLLM logging. Default ``dictConfig`` adds a formatted stream handler.
18
19 Supply a JSON object with ``--logging-config`` or individual fields with
20 dotted arguments such as ``--logging-config.log_level DEBUG`` and
21 ``--logging-config.formatter json``. ``--log-level`` and legacy
22 ``--log-config-file`` override their matching fields. Set
23 ``configure_logging`` to false to skip applying a ``dictConfig``.
24 """
25
26 log_level: LogLevel = Field(
27 default_factory=lambda: cast(LogLevel, envs.VLLM_LOGGING_LEVEL)
28 )
29 """Log level used when no custom logging configuration is provided."""
30
31 formatter: LogFormatter = "text"
32 """Formatter used by the built-in logging configuration."""
33
34 configure_logging: bool = Field(default_factory=lambda: envs.VLLM_CONFIGURE_LOGGING)
35 """Whether to apply a Python logging configuration.
36
37 With no ``pylogging_config_file``, the default config adds a formatted
38 stream handler to the ``vllm`` logger. A custom Python logging configuration
39 file also requires this to be enabled.
40 """
41
42 pylogging_config_file: str | None = Field(
43 default_factory=lambda: envs.VLLM_LOGGING_CONFIG_PATH
44 )
45 """Path to a Python logging JSON file using
46 [``dictConfig`` schema](https://docs.python.org/3/library/logging.config.html#configuration-file-format).
47
48 A custom ``dictConfig`` is authoritative over ``log_level`` and
49 ``formatter`` for logger, handler, and formatter settings.
50 """