Nhật ký lỗi truy vấn cho tiện ích bổ sung của Google Workspace
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Khi một tiện ích bổ sung Google Workspace đã xuất bản trả về lỗi, giao diện tiện ích bổ sung sẽ trả về thông báo chung là "Đã xảy ra lỗi khi thực thi tiện ích bổ sung". Tuy nhiên, các lỗi này sẽ được ghi vào Trình khám phá nhật ký trên đám mây.
Hướng dẫn này mô tả cách truy vấn nhật ký lỗi của tiện ích bổ sung trong
Trình khám phá nhật ký trên đám mây để bạn có thể:
Tìm hiểu xem người dùng có gặp lỗi hay không.
Xem tần suất xảy ra lỗi và lỗi nào thường gặp nhất.
Đọc thông báo lỗi mô tả để giúp bạn khắc phục lỗi.
Điều kiện tiên quyết
Trước khi truy vấn nhật ký lỗi của tiện ích bổ sung:
Bật "Cloud Logging API" (API ghi nhật ký trên đám mây) trong dự án Google Cloud của tiện ích bổ sung. Để bật API, hãy tham khảo phần Tạo dự án trên Cloud và bật API.
Xuất bản tiện ích bổ sung trên Google Workspace Marketplace.
Để phát hành tiện ích bổ sung trên Marketplace, hãy tham khảo phần Phát hành ứng dụng.
Để xem các lỗi gần đây, hãy nhấp vào Chạy truy vấn. Hoặc để xem lỗi khi lỗi xảy ra, hãy nhấp vào Nhật ký luồng. Nhật ký lỗi của tiện ích bổ sung sẽ xuất hiện trong ngăn "Kết quả truy vấn".
Để biết thêm thông tin về Trình khám phá nhật ký trên đám mây và cách viết truy vấn, hãy tham khảo nội dung sau:
[null,null,["Cập nhật lần gần đây nhất: 2024-12-22 UTC."],[[["\u003cp\u003eGoogle Workspace add-ons log errors to Cloud Logs Explorer, providing detailed error messages for troubleshooting.\u003c/p\u003e\n"],["\u003cp\u003eTo view these logs, enable the Cloud Logging API, publish your add-on, and then query the logs using the provided instructions and query.\u003c/p\u003e\n"],["\u003cp\u003eYou can control error logging behavior through the \u003ccode\u003eexceptionLogging\u003c/code\u003e setting in your add-on's manifest file.\u003c/p\u003e\n"],["\u003cp\u003eRemember that only errors are logged, messages are in English, and Cloud Logging usage may incur costs.\u003c/p\u003e\n"]]],["Published Google Workspace add-on errors are logged in Cloud Logs Explorer, offering detailed insights beyond the generic interface message. To access these logs, enable the \"Cloud Logging API\" and publish the add-on. Query logs in the Logs Explorer using `severity\u003e=ERROR` and `protoPayload.serviceName=\"gsuiteaddons.googleapis.com\"`. Error logging is enabled by default, controlled via the `exceptionLogging` key in the manifest file. Only errors are logged, messages are always in English, and Cloud Logging incurs costs.\n"],null,["# Query error logs for Google Workspace add-ons\n\nWhen a published Google Workspace add-on returns an error, the\nadd-on interface returns a generic message of\n\"Something went wrong when executing the add-on.\" However, these errors are\nlogged to [Cloud Logs Explorer](https://cloud.google.com/logging/docs/view/logs-viewer-interface).\n| **Note:** For Apps Script, if your add-on is deployed as a test, then errors are reported in both the Cloud Logs Explorer and in the add-on interface.\n|\n|\n| For example, an add-on test deployment might display an\n| error message like this in its interface: `TypeError:\n| card.INVALIDFUNCTIONNAME\n| is not a function [line: 33, function: getContextualAddOn, file:\n| GetContextualAddOn]`.\n|\n|\n| Although error messages like this are helpful, additional information is\n| available in the Logs Explorer. As a best practice, query the error logs for\n| more information. For further information about testing\n| add-on deployments, refer to\n| [Test and debug Google Workspace add-ons](/workspace/add-ons/guides/debug).\n\nThis guide describes how to query add-on error logs in\nCloud Logs Explorer, so you can:\n\n- Learn if users encounter errors.\n- See how often errors occur, and which are most frequent.\n- Read descriptive error messages that help you fix them.\n\nPrerequisites\n-------------\n\nBefore querying add-on error logs:\n\n- Enable the \"Cloud Logging API\" in the add-on's Google Cloud project. To enable an API, refer to [Create a Cloud project and enable the API](/workspace/guides/create-project).\n- Publish the add-on on Google Workspace Marketplace. To publish an add-on on the Marketplace, refer to [Publish an app](/workspace/marketplace/how-to-publish).\n\nQuery add-on error logs\n-----------------------\n\nTo get logs for an add-on:\n\n1. Open the [Google Cloud console](https://console.cloud.google.com/).\n2. Next to \"Google Cloud Platform,\" click the Down arrow arrow_drop_down and select the add-on project.\n3. In the top-left corner, click Menu menu \\\u003e **Logging**. The Logs Explorer opens.\n4. For add-on error logs, in the query builder, enter\n the following query:\n\n severity\u003e=ERROR\n protoPayload.serviceName=\"gsuiteaddons.googleapis.com\"\n\n5. To see recent errors, click **Run query** . Or, to see errors as they\n occur, click **Stream logs**. Add-ons error logs appear in the\n \"Query results\" pane.\n\nFor further information about Cloud Logs Explorer and writing queries, refer to\nthe following:\n\n- [Use the Logs Explorer](https://cloud.google.com/logging/docs/view/logs-viewer-interface)\n- [Build queries](https://cloud.google.com/logging/docs/view/building-queries)\n\nEnable or disable error logging\n-------------------------------\n\nBy default, error logging is enabled. When error logging is enabled, the\n[manifest file](/workspace/add-ons/concepts/workspace-manifests)\nhas the following: \n\n \"exceptionLogging\": \"STACKDRIVER\",\n\nTo disable error logging, replace\n`\"exceptionLogging\": \"STACKDRIVER\",` with the following line in the\nmanifest file: \n\n // Disable error logging\n \"exceptionLogging\": \"NONE\"\n\nTo re-enable error logging, replace `\"exceptionLogging\": \"NONE\"` with\n`\"exceptionLogging\": \"STACKDRIVER\",`.\n\nConsiderations\n--------------\n\nAs you work with add-on error logs in Cloud Logs\nExplorer, take note of these considerations:\n\n- Add-ons only log errors in Logs Explorer. Other log types are not recorded.\n- Error messages are always written in English.\n- Cloud Logging incurs a cost. For further information about Cloud Logging pricing, refer to [Google Cloud Observability pricing](https://cloud.google.com/stackdriver/pricing)."]]