{"record":{"id":"84fb0575e42b49f4","repo":"sgl-project/sglang","slug":"invalid-log-requests-level-self-log-requests-l","errorCode":null,"errorMessage":"Invalid --log-requests-level: {self.log_requests_level=}","messagePattern":"Invalid --log-requests-level: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/utils/request_logger.py","lineNumber":230,"sourceCode":"                out_skip_names = {\"text\", \"output_ids\", \"embedding\"}\n            elif self.log_requests_level == 1:\n                max_length = 1 << 30\n                skip_names = {\n                    \"text\",\n                    \"input_ids\",\n                    \"input_embeds\",\n                    \"image_data\",\n                    \"audio_data\",\n                    \"video_data\",\n                    \"lora_path\",\n                }\n                out_skip_names = {\"text\", \"output_ids\", \"embedding\"}\n            elif self.log_requests_level == 2:\n                max_length = 2048\n            elif self.log_requests_level == 3:\n                max_length = 1 << 30\n            else:\n                raise ValueError(\n                    f\"Invalid --log-requests-level: {self.log_requests_level=}\"\n                )\n        return max_length, skip_names, out_skip_names\n\n    def _log(self, msg: str) -> None:\n        for target in self.targets:\n            target.info(msg)\n\n\n# TODO unify this w/ `_transform_data_for_logging` if we find performance enough\ndef _dataclass_to_string_truncated(\n    data: Any, max_length: int = 2048, skip_names: Optional[Set[str]] = None\n) -> str:\n    if skip_names is None:\n        skip_names = set()\n    if isinstance(data, str):\n        if len(data) > max_length:\n            half_length = max_length // 2","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/utils/request_logger.py#L212-L248","documentation":"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.","triggerScenarios":"Launching with --log-requests-level 4 (or -1) together with an output target configured; _compute_metadata runs during __init__/configure.","commonSituations":"Typos in launch flags, scripts incrementing the level beyond 3, or stale configs written against a different level range.","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"],"exampleFix":"# before\n--log-requests-level 4\n# after\n--log-requests-level 3","handlingStrategy":"validation","validationCode":"assert log_requests_level in (0, 1, 2, 3), f'--log-requests-level must be 0-3, got {log_requests_level}'","typeGuard":"def is_valid_log_level(v) -> bool:\n    return v in (0, 1, 2, 3)","tryCatchPattern":"try:\n    RequestLogger(...)\nexcept ValueError as e:\n    if 'log-requests-level' in str(e):\n        level = 1; RequestLogger(...)","preventionTips":["Validate CLI args before passing to launch","Document allowed levels in runbooks","Add argparse choices=[0,1,2,3] in wrapper scripts"],"tags":["logging","cli-args","request-logging","sglang"],"backgroundTag":"invalid-cli-argument-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}