为 Google Chat 应用开启错误日志记录功能

本页介绍了如何开启 Chat 应用错误日志记录,以便您在测试 Chat 应用时,可以在 Google Cloud 日志浏览器中查询和查看错误日志。

前提条件

如需开启 Chat 应用错误日志记录功能,您需要:

  • 拥有 Google Chat 访问权限的 Google Workspace 账号。
  • 一个 Chat 应用。如需构建 Chat 应用,请按照此快速入门操作。

设置环境

在查询 Chat 应用错误日志之前,您必须在 Chat 应用的 Google Cloud 项目中启用 Cloud Logging API。

  1. 在 Google Cloud 控制台中,开启 Cloud Logging API。依次点击菜单 > API 和服务 > > 搜索 Cloud Logging API > 点击 Cloud Logging API > 点击启用

    启用该 API

开启错误日志记录

启用错误日志记录功能,当 Chat 应用返回错误时,系统会将该错误记录到 Cloud Logging。由于 Cloud Logging 会产生费用,因此您可能需要在完成问题排查后关闭错误日志记录

  1. 在 Google Cloud 控制台中,前往 Chat API 配置页面。依次点击菜单图标 > 更多产品 > Google Workspace > 产品库 > Google Chat API > 管理 > 配置

    前往 Chat API

  2. 在“功能”下,选择将错误记录到 Cloud Logging

  3. 点击保存

现在,每当 Chat 应用返回错误时,该错误都会记录到 Cloud Logging。

关闭错误日志记录

由于 Cloud Logging 会产生费用,您可能需要关闭错误日志记录功能。

  1. 在 Google Cloud 控制台中,前往 Chat API 配置页面。依次点击菜单图标 > 更多产品 > Google Workspace > 产品库 > Google Chat API > 管理 > 配置

    前往 Chat API

  2. 在“功能”下,取消选中将错误记录到 Cloud Logging

  3. 点击保存

现在,每当 Chat 应用返回错误时,该错误都不会记录到 Cloud Logging。您可以使用 Logs Explorer 继续查询过往的错误日志。

开启错误日志记录功能后,您就可以查询 Chat 应用的错误日志了。