Skip to content
LangSmith 文档版本 跟随上游 源快照 4bfb6b28 更新于 2026-10-18

在服务器日志中包含 HTTP 请求头

出于隐私原因,Agent Server 默认会在服务器日志中省略 HTTP 请求头。然而,记录请求 ID 和关联 ID 可以帮助你调试问题,并在分布式系统中追踪请求。你可以通过修改 langgraph.json 文件中的 logging_headers 部分,选择为所有 API 调用记录请求头。

json
{
  "$schema": "https://langgra.ph/schema.json",
  "http": {
    "logging_headers": {
      "includes": ["request-id", "x-purchase-id", "*-trace-*"],
      "excludes": ["authorization", "x-api-key", "x-organization-id", "x-user-id"]
    }
  }
}

includes 和 excludes 列表接受精确的请求头名称,或使用 * 作为通配符以匹配任意数量字符的 glob 模式(不区分大小写)。出于安全考虑,不支持其他类型的模式。

请注意,排除优先于包含。例如,如果你包含 *-id 但排除 x-user-id,那么 x-user-id 请求头将不会被记录。


BytesRouter 是社区翻译站点,所有译文仅供参考,一切以官方英文原文为准。