日志记录
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
向 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=
指定日志记录器。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-21。
[null,null,["最后更新时间 (UTC):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=`."]]