記錄
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
您可以使用自己的自訂記錄器,或 Perl 用戶端程式庫中的預設記錄器,記錄對 Google Ads API 提出的要求、回應和摘要訊息。
記錄層級
程式庫會將不同類型的事件記錄到不同的記錄層級。如果 API 回應成功,系統會在 INFO
記錄摘要,並在 DEBUG
記錄完整要求和回應。如果要求導致 API 發生錯誤,系統會在 WARN
記錄摘要訊息,並在 INFO
記錄完整要求和回應。
記錄類型 |
記錄檔名稱 |
成功等級 |
失敗等級 |
摘要 |
Google.Ads.GoogleAds.Summary |
資訊 |
WARN |
詳細資料 |
Google.Ads.GoogleAds.Detail |
偵錯 |
資訊 |
如果是部分失敗,部分失敗的詳細資料會記錄在 DEBUG
。
設定
用戶端程式庫會使用自訂類別處理所有記錄作業,並透過 GoogleAdsLogger 模組公開。這個類別提供預設設定,摘要和詳細記錄器都會將記錄寫入 HOME
目錄下 logs
資料夾中的相對檔案。不過,您可以在 HOME
目錄中提供 log4perl.conf 檔案,覆寫預設設定。
您可以使用下列方法啟用/停用記錄功能:
啟用兩個記錄器的記錄功能。
Google::Ads::GoogleAds::Logging::GoogleAdsLogger::enable_all_logging();
停用摘要記錄。
Google::Ads::GoogleAds::Logging::GoogleAdsLogger::disable_summary_logging();
停用詳細記錄。
Google::Ads::GoogleAds::Logging::GoogleAdsLogger::disable_detail_logging();
您可以直接使用 GoogleAdsLogger
類別的方法,進一步控管記錄要求的方式。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-27 (世界標準時間)。
[null,null,["上次更新時間:2025-08-27 (世界標準時間)。"],[[["\u003cp\u003eThe Google Ads API client library for Perl allows logging of requests, responses, and summaries using a custom or default logger.\u003c/p\u003e\n"],["\u003cp\u003eLogging levels include \u003ccode\u003eINFO\u003c/code\u003e, \u003ccode\u003eDEBUG\u003c/code\u003e, and \u003ccode\u003eWARN\u003c/code\u003e, used to categorize different event types like successes, failures, and partial failures.\u003c/p\u003e\n"],["\u003cp\u003eThe default logger configuration saves logs to the \u003ccode\u003elogs\u003c/code\u003e folder in your home directory, which can be customized by providing a \u003ccode\u003elog4perl.conf\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eLogging can be controlled through the \u003ccode\u003eGoogleAdsLogger\u003c/code\u003e module, allowing for enabling/disabling logging or more advanced customization.\u003c/p\u003e\n"]]],[],null,["# Logging\n\nRequests, responses, and summary messages made to the Google Ads API can be\nlogged with your own custom logger or the default logger in the client library\nfor Perl.\n\nLog Levels\n----------\n\nThe library will log different types of events to different log levels. On a\nsuccessful API response, the summary will be logged at `INFO`, and the full\nrequest and responses will be logged at `DEBUG`. On a request that resulted in\nan API error, the summary message will be logged at `WARN` and the full request\nand response will be logged at `INFO`.\n\n| Log type | Log name | Success level | Failure level |\n|----------|------------------------------|---------------|---------------|\n| SUMMARY | Google.Ads.GoogleAds.Summary | INFO | WARN |\n| DETAIL | Google.Ads.GoogleAds.Detail | DEBUG | INFO |\n\nFor partial failures, the partial failure details will be logged at `DEBUG`.\n\nConfiguration\n-------------\n\nThe client library uses a custom class for all logging purposes and is exposed\nthrough the [GoogleAdsLogger](https://github.com/googleads/google-ads-perl/blob/HEAD/lib/Google/Ads/GoogleAds/Logging/GoogleAdsLogger.pm)\nmodule. This class provides a default configuration that both summary and detail\nloggers will log to relative files in the `logs` folder under your `HOME` directory.\nBut the default configuration can be overridden by providing a\n[log4perl.conf](https://github.com/googleads/google-ads-perl/blob/HEAD/log4perl.conf)\nfile in your `HOME` directory.\n\nLogging can be enabled/disabled using the following methods:\n\n- Enables logging for both loggers.\n\n Google::Ads::GoogleAds::Logging::GoogleAdsLogger::enable_all_logging();\n\n- Disables the summary logging.\n\n Google::Ads::GoogleAds::Logging::GoogleAdsLogger::disable_summary_logging();\n\n- Disables the detail logging.\n\n Google::Ads::GoogleAds::Logging::GoogleAdsLogger::disable_detail_logging();\n\nYou can use the methods of the `GoogleAdsLogger` class directly for even more\ncontrol over how requests are logged."]]