本頁說明如何啟用 Chat 應用程式錯誤記錄功能,以便在測試 Chat 應用程式時,透過 Google Cloud 記錄檔探索工具查詢及查看錯誤記錄。
必備條件
如要開啟 Chat 應用程式錯誤記錄功能,你必須:
- 擁有可存取 Google Chat 的 Google Workspace 帳戶。
- Chat 應用程式。如要建構 Chat 應用程式,請按照quickstart操作。
設定環境
查詢 Chat 應用程式錯誤記錄前,您必須在 Chat 應用程式的 Google Cloud 專案中啟用 Cloud Logging API。
在 Google Cloud 控制台中開啟 Cloud Logging API。依序點選「Menu」>「APIs & Services」>「Library」。> 搜尋「Cloud Logging API」> 按一下「Cloud Logging API」>「啟用」。
啟用錯誤記錄功能
您可以啟用錯誤記錄功能,每當 Chat 應用程式傳回錯誤時,系統就會記錄至 Cloud Logging。由於 Cloud Logging 會產生費用,因此建議您在完成疑難排解後關閉錯誤記錄功能。
前往 Google Cloud 控制台的 Chat API「設定」頁面。依序按一下「選單」>「更多產品」 >「Google Workspace」 >「產品資料庫」 >「Google Chat API」 >「管理」 >「設定」。
在「功能」下方,選取「將錯誤記錄到 Cloud Logging」。
點按「儲存」。
現在,每當 Chat 應用程式傳回錯誤,系統都會將錯誤記錄至 Cloud Logging。
關閉錯誤記錄
Cloud Logging 會產生費用,因此建議您關閉錯誤記錄功能。
前往 Google Cloud 控制台的 Chat API「設定」頁面。依序按一下「選單」>「更多產品」 >「Google Workspace」 >「產品資料庫」 >「Google Chat API」 >「管理」 >「設定」。
在「功能」下方,取消選取「將錯誤記錄到 Cloud Logging」。
點按「儲存」。
現在,每當 Chat 應用程式傳回錯誤,就不會將錯誤記錄到 Cloud Logging。您可以繼續使用記錄檔探索工具查詢過去的錯誤記錄檔。
相關主題
啟用錯誤記錄功能後,就可以針對 Chat 應用程式查詢錯誤記錄。