開啟 Google Chat 應用程式的錯誤記錄功能
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本頁說明如何啟用 Chat 應用程式錯誤記錄功能,以便在測試 Chat 應用程式時,透過 Google Cloud 記錄探索工具查詢及查看錯誤記錄。
必要條件
如要啟用 Chat 應用程式錯誤記錄功能,您需要:
- 可存取 Google Chat 的 Google Workspace 帳戶。
- Chat 應用程式。如要建構 Chat 應用程式,請按照這篇快速入門指南操作。
設定環境
查詢 Chat 應用程式錯誤記錄前,請先在 Chat 應用程式的 Google Cloud 專案中啟用 Cloud Logging API。
在 Google Cloud 控制台中,開啟 Cloud Logging API。依序點選「選單」menu「API 和服務」「程式庫」。> 搜尋「Cloud Logging API」
> 點按「Cloud Logging API」
> 點按「啟用」。
啟用 API
啟用錯誤記錄
開啟錯誤記錄功能後,如果 Chat 應用程式傳回錯誤,系統就會將錯誤記錄至 Cloud Logging。由於 Cloud Logging 會產生費用,因此完成疑難排解後,您可能會想關閉錯誤記錄。
在 Google Cloud 控制台中,前往 Chat API 設定頁面。依序點選「選單」
menu
「更多產品」
「Google Workspace」
「產品庫」
「Google Chat API」
「管理」
「設定」。
前往 Chat API
在「功能」下方,選取「將錯誤記錄至 Cloud Logging」。
按一下 [儲存]。
現在,每當 Chat 應用程式傳回錯誤時,系統就會將錯誤記錄至 Cloud Logging。
關閉錯誤記錄功能
由於 Cloud Logging 會產生費用,您可能需要關閉錯誤記錄功能。
在 Google Cloud 控制台中,前往 Chat API 設定頁面。依序點選「選單」
menu
「更多產品」
「Google Workspace」
「產品庫」
「Google Chat API」
「管理」
「設定」。
前往 Chat API
在「功能」下方,取消選取「將錯誤記錄至 Cloud Logging」。
按一下 [儲存]。
現在,每當 Chat 應用程式傳回錯誤時,系統不會將錯誤記錄至 Cloud Logging。您仍可使用記錄檔探索工具查詢過往的錯誤記錄。
開啟錯誤記錄功能後,即可查詢 Chat 應用程式的錯誤記錄。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-04 (世界標準時間)。
[null,null,["上次更新時間:2025-08-04 (世界標準時間)。"],[[["\u003cp\u003eThis guide explains how to enable error logging for your Google Chat app, allowing you to view and analyze errors in Google Cloud Logs Explorer.\u003c/p\u003e\n"],["\u003cp\u003eTo enable error logging, you need a Google Workspace account, a Chat app, and the Cloud Logging API enabled in your Google Cloud project.\u003c/p\u003e\n"],["\u003cp\u003eWhen enabled, Chat app errors are logged to Cloud Logging, which may incur costs; you can disable logging after troubleshooting.\u003c/p\u003e\n"],["\u003cp\u003eYou can turn off error logging to avoid incurring costs from Cloud Logging, but you can still query past logs.\u003c/p\u003e\n"]]],["To enable Chat app error logging, first enable the Cloud Logging API in the Google Cloud console. Then, navigate to the Chat API configuration page and under Functionality, select \"Log errors to Cloud Logging,\" and save. Errors are now logged to Cloud Logging. To disable, deselect \"Log errors to Cloud Logging\" and save. Remember to disable it when troubleshooting is complete, as Cloud Logging incurs a cost. Error logs can be viewed in Google Cloud Logs Explorer.\n"],null,["This page describes how to turn on Chat app error logging, so that you can query and view error logs in [Google Cloud Logs Explorer](https://cloud.google.com/logging/docs/view/logs-viewer-interface) while testing your Chat app.\n\nPrerequisites\n\nTo turn on Chat app error logging, you need:\n\n- A Google Workspace account with access to Google Chat.\n- A Chat app. To build a Chat app, follow this [quickstart](/workspace/chat/quickstart/gcf-app).\n\nSet up the environment\n\nBefore querying Chat app error logs, you must enable the Cloud Logging API in the Chat app's Google Cloud project.\n\n1. In the Google Cloud console, turn on the Cloud Logging API. Click **Menu**\n menu\n \\\u003e **APIs \\& Services**\n \\\u003e **Library** .\n \\\u003e search for **Cloud Logging API**\n \\\u003e click **Cloud Logging API**\n \\\u003e **Enable**.\n\n [Enable the API](https://console.cloud.google.com/marketplace/product/google/logging.googleapis.com)\n\nTurn on error logging\n\nTurn on error logging and when a Chat app returns an error, it logs it to Cloud logging. Because Cloud Logging [incurs a cost](https://cloud.google.com/stackdriver/pricing), you might want to [turn off error logging](#turn-off-error-logging) after you finish troubleshooting.\n\n1. In the Google Cloud console, go to the Chat API **configuration** page. Click **Menu**\n menu\n \\\u003e **More products**\n \\\u003e **Google Workspace**\n \\\u003e **Product Library**\n \\\u003e **Google Chat API**\n \\\u003e **Manage**\n \\\u003e **Configuration**.\n\n [Go to Chat API](https://console.cloud.google.com/apis/api/chat.googleapis.com/hangouts-chat)\n2. Under Functionality, select **Log errors to Cloud Logging**.\n\n3. Click **Save**.\n\nNow, whenever the Chat app returns an error, the error gets logged to Cloud Logging.\n\nTurn off error logging\n\nBecause Cloud Logging [incurs a cost](https://cloud.google.com/stackdriver/pricing), you might want to turn off error logging.\n\n1. In the Google Cloud console, go to the Chat API **configuration** page. Click **Menu**\n menu\n \\\u003e **More products**\n \\\u003e **Google Workspace**\n \\\u003e **Product Library**\n \\\u003e **Google Chat API**\n \\\u003e **Manage**\n \\\u003e **Configuration**.\n\n [Go to Chat API](https://console.cloud.google.com/apis/api/chat.googleapis.com/hangouts-chat)\n2. Under Functionality, deselect **Log errors to Cloud Logging**.\n\n3. Click **Save**.\n\nNow, whenever the Chat app returns an error, the error doesn't get logged to Cloud Logging. You can continue to query past error logs using Logs Explorer.\n\nRelated topics\n\nAfter turning on error logging, you're ready to [query error logs](/workspace/chat/query-logs) for your Chat app."]]