開啟 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-02-16 (世界標準時間)。
[null,null,["上次更新時間:2025-02-16 (世界標準時間)。"],[[["This guide explains how to enable error logging for your Google Chat app, allowing you to view and analyze errors in Google Cloud Logs Explorer."],["To enable error logging, you need a Google Workspace account, a Chat app, and the Cloud Logging API enabled in your Google Cloud project."],["When enabled, Chat app errors are logged to Cloud Logging, which may incur costs; you can disable logging after troubleshooting."],["You can turn off error logging to avoid incurring costs from Cloud Logging, but you can still query past logs."]]],["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"]]