网络跟踪
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
借助网络跟踪功能,您可以查看与 Google 移动广告 SDK 相关的网络活动。该功能非常适合调试 Google 移动广告的实现。
使用网络跟踪功能而非 Charles Proxy 等工具的主要原因是:网络跟踪功能适用于所有 iOS 版本和设备,无需信任任何第三方安全证书配置文件。自 iOS 10.3 以来,由于相关的证书配置文件要求,代理工具并不具备如此广泛的适用性。
本指南介绍了如何出于调试目的而启用网络跟踪功能。
启用跟踪功能
如需启用网络跟踪功能,请在 plist 文件中将 GADEnableNetworkTracing
键设置为 YES
。
启用网络跟踪功能后,Google 移动广告 SDK 会将网络事件记录到控制台。然后,您可以将日志副本提供给我们的工程师,以便他们将其作为开发者论坛上的私人回复进行分析。
日志记录
适用于标准平台的控制台日志用于输出网络日志。
控制台日志消息始终以字符串 GMA Debug BEGIN
、GMA Debug CONTENT
或 GMA Debug FINISH
开头,因此您可以对其进行搜索或滤除。对于每个网络日志,第一条日志消息为 GMA Debug BEGIN
,最后一条日志消息为 GMA Debug FINISH
,并且网络日志内容以 GMA Debug CONTENT
开头。如果网络日志内容过长,无法完全显示在一行中,则会将其拆分为多行,且每一行都以 GMA Debug CONTENT
开头。
示例输出
<Your App Name>[2710:30568] <Google> GMA Debug BEGIN
2017-12-06 09:47:09.268020-0800 <Your App Name>[2710:30568] <Google> GMA Debug CONTENT: {
"components" : [
"network_request_31107D12-E54E-45D6-AEA9-4A303C659EDF"
],
"timestamp" : 1512582429267.2629,
"event" : "onNetworkRequest",
"params" : {
"firstline" : {
"uri" : "<encoded text>",
"verb" : "<encoded text>"
},
"headers" : [
{
"name" : "<encoded text>",
"value" : "<encoded text>"
}
]
}
}
2017-12-06 09:47:09.275742-0800 <Your App Name>[2710:30568] <Google> GMA Debug FINISH
然后,您可以将日志副本提供给我们的工程师进行分析。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-24。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-24。"],[[["Network tracing allows debugging of the Google Mobile Ads SDK by revealing network activities."],["It works on all iOS versions and devices without needing third-party security certificate profiles, unlike proxying tools."],["To enable, set the `GADEnableNetworkTracing` key to `YES` in your app's plist file."],["Network event logs are output to the console, starting with \"GMA Debug BEGIN\" and ending with \"GMA Debug FINISH\"."],["Share the console logs with Google engineers for analysis to help with debugging."]]],["Network tracing, used for debugging the Google Mobile Ads SDK, works on all iOS versions without needing third-party security certificates. To enable it, set `GADEnableNetworkTracing` to `YES` in your plist file. Network events are logged to the console, with messages starting with `GMA Debug BEGIN`, `GMA Debug CONTENT`, or `GMA Debug FINISH`. These logs can then be provided to engineers for analysis via the developer forum. Each network log includes content, timestamp, and event parameters.\n"]]