sgl-project/sglang · error · ValueError
Invalid --log-requests-level: {self.log_requests_level=}
Error message
Invalid --log-requests-level: {self.log_requests_level=} What it means
RequestLogger validates --log-requests-level: with output logging enabled, only levels 0-3 are accepted (2 => max_length 2048, 3 => ~1GB, etc.). Any other integer raises ValueError echoing the value.
Source
Thrown at python/sglang/srt/utils/request_logger.py:230
out_skip_names = {"text", "output_ids", "embedding"}
elif self.log_requests_level == 1:
max_length = 1 << 30
skip_names = {
"text",
"input_ids",
"input_embeds",
"image_data",
"audio_data",
"video_data",
"lora_path",
}
out_skip_names = {"text", "output_ids", "embedding"}
elif self.log_requests_level == 2:
max_length = 2048
elif self.log_requests_level == 3:
max_length = 1 << 30
else:
raise ValueError(
f"Invalid --log-requests-level: {self.log_requests_level=}"
)
return max_length, skip_names, out_skip_names
def _log(self, msg: str) -> None:
for target in self.targets:
target.info(msg)
# TODO unify this w/ `_transform_data_for_logging` if we find performance enough
def _dataclass_to_string_truncated(
data: Any, max_length: int = 2048, skip_names: Optional[Set[str]] = None
) -> str:
if skip_names is None:
skip_names = set()
if isinstance(data, str):
if len(data) > max_length:
half_length = max_length // 2View on GitHub (pinned to 0132848349)
Solutions
- Use a valid level: 0 (off/simple), 1, 2, or 3
- Check the --log-requests-level docs/help for the accepted range
- If the intent is 'log everything', use level 3
Example fix
# before --log-requests-level 4 # after --log-requests-level 3
Defensive patterns
Strategy: validation
Validate before calling
assert log_requests_level in (0, 1, 2, 3), f'--log-requests-level must be 0-3, got {log_requests_level}' Type guard
def is_valid_log_level(v) -> bool:
return v in (0, 1, 2, 3) Try / catch
try:
RequestLogger(...)
except ValueError as e:
if 'log-requests-level' in str(e):
level = 1; RequestLogger(...) Prevention
- Validate CLI args before passing to launch
- Document allowed levels in runbooks
- Add argparse choices=[0,1,2,3] in wrapper scripts
When it happens
Trigger: Launching with --log-requests-level 4 (or -1) together with an output target configured; _compute_metadata runs during __init__/configure.
Common situations: Typos in launch flags, scripts incrementing the level beyond 3, or stale configs written against a different level range.
Related errors
- Quantization method specified in the model config ({quant_me
- --mamba-cache-philox-rounds must be non-negative.
- Unknown serve backend {name!r}. Available values: {available
- Multiple distributions register serve backend {name!r}: {pro
- Failed to load serve backend {name!r} from {self._entry_poin
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/84fb0575e42b49f4.
Report an issue: GitHub.