如何使用Google Analytics 7.3抑制日志记录?

时间:2021-12-21 15:24:44

The latest update to Google Play Services 7.3 makes GA's Logger interface deprecated, and thus we cannot control the logging level from inside our app anymore.

Google Play Services 7.3的最新更新使得GA的Logger界面不再使用,因此我们无法再从我们的应用程序内部控制日志记录级别。

This interface is deprecated.

不推荐使用此接口。

Logger interface is deprecated. Use adb shell setprop log.tag.GAv4 DEBUG to enable debug logging for Google Analytics.

不推荐使用Logger接口。使用adb shell setprop log.tag.GAv4 DEBUG为Google Analytics启用调试日志记录。

We used to have different settings per build type, using Logger.setLogLevel() (the guide seems to be outdated): verbose for debug and error for release, so that our tracking information is available only to us during development.

我们以前每种构建类型都有不同的设置,使用Logger.setLogLevel()(指南似乎已经过时):详细调试和发布错误,因此我们的跟踪信息仅在开发期间可供我们使用。

Now with latest update, anyone who can run

现在有最新的更新,任何人都可以运行

adb shell setprop log.tag.GAv4 VERBOSE

will be able to see what we are sending to Google Analytics, or anyone can see what everyone else is logging (those who use 7.3).

我们可以看到我们发送给Google Analytics的内容,或者任何人都可以看到其他人正在登录的内容(使用7.3的人)。

Is there any way to avoid this?

有什么方法可以避免这种情况吗?

2 个解决方案

#1


In the Google Analytics changelog page you can see that GA Version 4.5 is the version which is included in Google Play Services 7.3 (May 1, 2015)

在Google Analytics更改日志页面中,您可以看到GA版本4.5是Google Play服务7.3中包含的版本(2015年5月1日)

https://developers.google.com/analytics/devguides/changelog

You can change the default Logger to a custom implementation:

您可以将默认记录器更改为自定义实现:

Custom implementations of Logger can also be used:

// Provide a custom logger.
GoogleAnalytics.getInstance(this).setLogger(new CustomLogger());

See: https://developers.google.com/analytics/devguides/collection/android/v4/advanced

#2


According to documentation use adb shell setprop log.tag.GAv4 DEBUG in android studio terminal but make sure you connect one device only then enter adb logcat -v time -s GAv4 in terminal to start track logger

根据文档在android studio终端中使用adb shell setprop log.tag.GAv4 DEBUG但确保你只连接一台设备然后在终端输入adb logcat -v time -s GAv4以启动跟踪记录器

Logger

Google Analytics will log to logcat under the GAv4 tag using the Android Log system. By default only ERROR, WARN and INFO levels are enabled. To enable DEBUG level run the following adb command on your device or emulator:

Google Analytics将使用Android Log系统在GAv4标记下登录logcat。默认情况下,仅启用ERROR,WARN和INFO级别。要启用DEBUG级别,请在您的设备或模拟器上运行以下adb命令:

adb shell setprop log.tag.GAv4 DEBUG To see only Google Analytics messages from logcat use the following command:

adb shell setprop log.tag.GAv4 DEBUG要仅查看来自logcat的Google Analytics消息,请使用以下命令:

adb logcat -v time -s GAv4

adb logcat -v time -s GAv4

reference https://developers.google.com/analytics/devguides/collection/android/v4/advanced#logger

#1


In the Google Analytics changelog page you can see that GA Version 4.5 is the version which is included in Google Play Services 7.3 (May 1, 2015)

在Google Analytics更改日志页面中,您可以看到GA版本4.5是Google Play服务7.3中包含的版本(2015年5月1日)

https://developers.google.com/analytics/devguides/changelog

You can change the default Logger to a custom implementation:

您可以将默认记录器更改为自定义实现:

Custom implementations of Logger can also be used:

// Provide a custom logger.
GoogleAnalytics.getInstance(this).setLogger(new CustomLogger());

See: https://developers.google.com/analytics/devguides/collection/android/v4/advanced

#2


According to documentation use adb shell setprop log.tag.GAv4 DEBUG in android studio terminal but make sure you connect one device only then enter adb logcat -v time -s GAv4 in terminal to start track logger

根据文档在android studio终端中使用adb shell setprop log.tag.GAv4 DEBUG但确保你只连接一台设备然后在终端输入adb logcat -v time -s GAv4以启动跟踪记录器

Logger

Google Analytics will log to logcat under the GAv4 tag using the Android Log system. By default only ERROR, WARN and INFO levels are enabled. To enable DEBUG level run the following adb command on your device or emulator:

Google Analytics将使用Android Log系统在GAv4标记下登录logcat。默认情况下,仅启用ERROR,WARN和INFO级别。要启用DEBUG级别,请在您的设备或模拟器上运行以下adb命令:

adb shell setprop log.tag.GAv4 DEBUG To see only Google Analytics messages from logcat use the following command:

adb shell setprop log.tag.GAv4 DEBUG要仅查看来自logcat的Google Analytics消息,请使用以下命令:

adb logcat -v time -s GAv4

adb logcat -v time -s GAv4

reference https://developers.google.com/analytics/devguides/collection/android/v4/advanced#logger