記錄
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
向 Google Ads API 發出的要求、回應和摘要訊息可記錄到您自己的自訂記錄器或 Ruby 程式庫中的預設記錄器。
記錄檔層級
程式庫會將不同類型的事件記錄至不同的記錄層級。如果 API 成功回應,摘要會在 INFO
記錄,完整的要求與回應則會記錄在 DEBUG
。如果要求導致 API 錯誤,摘要訊息會記錄在 WARN
,完整的要求與回應則會記錄在 INFO
。
針對部分失敗,系統會在 DEBUG
記錄部分失敗的詳細資料。
設定
您可以在 google_ads_config.rb 設定中設定記錄器。您可以指定 log_level
和 log_target
欄位來設定預設記錄器,也可以指定 logger
完全指定記錄器。如果您指定 logger
,系統就會忽略 log_level
和 log_target
。
您也可以在用戶端執行個體化後,使用 client.logger=
指定記錄器。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-21 (世界標準時間)。
[null,null,["上次更新時間:2025-08-21 (世界標準時間)。"],[[["\u003cp\u003eThe Google Ads API Ruby library allows logging of requests, responses, and summaries to custom or default loggers.\u003c/p\u003e\n"],["\u003cp\u003eDifferent log levels are used for successful responses (\u003ccode\u003eINFO\u003c/code\u003e, \u003ccode\u003eDEBUG\u003c/code\u003e) and errors (\u003ccode\u003eWARN\u003c/code\u003e, \u003ccode\u003eINFO\u003c/code\u003e, \u003ccode\u003eDEBUG\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eLogging can be configured through the \u003ccode\u003egoogle_ads_config.rb\u003c/code\u003e file using \u003ccode\u003elog_level\u003c/code\u003e, \u003ccode\u003elog_target\u003c/code\u003e, or a custom \u003ccode\u003elogger\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAfter client instantiation, the logger can be specified using \u003ccode\u003eclient.logger=\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Logging\n\nRequests, responses, and summary messages made to the Google Ads API can be\nlogged to your own custom logger or a default logger in the Ruby library.\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\nFor partial failures, the partial failure details will be logged at `DEBUG`.\n\nConfiguration\n-------------\n\nThe logger can be configured as part of your\n[google_ads_config.rb](https://github.com/googleads/google-ads-ruby/blob/HEAD/google_ads_config.rb)\nconfiguration. You can set up a default logger by specifying the `log_level` and\n`log_target` fields, or you can specify your own logger entirely by specifying\n`logger`. If you specify `logger`, then `log_level` and `log_target` will be\nignored.\n\nYou can also specify a logger after instantiating the client using\n`client.logger=`."]]