当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Should logs be disabled before releasing app?

问题描述:

I am about to release an app. Should I remove Log statements and e.printStackTrace() within the catch statements ?

网友答案:

Logs are essential troubleshooting resources, even for deployed software.

I would limit logging for production releases (perhaps even limit it to "only log in emergencies"). But I would not categorically say "no logging".

Here is a good discussion (with some good guidelines):

  • Android logging

PS: Having said that, I hasten to add:

No, you should not have any "debug" or "informational" logging in a production release.

Which is exactly what the Android documentation, cited in the above links, also says.

网友答案:

This is generally considered to be a good practice because:

  • If your log statements are enclose inside if statements on a debug flag, and you set that flag to false then when you compile your project, these statements are automatically left out, reducing the size of your apk, though not by much.
  • Since the log is shared with every other app, it is considerate to not have these messages in a production app as it will clutter other developer's logcat up when they debug.
  • Sometimes, you may be logging sensitive data like signatures, keys, passwords, emails, usernames etc. Disabling the logging can prevent your app from accidentally leaking such information.
网友答案:

Sometimes having logs enabled can create security issues. Most Android applications don't need to worry about this for several reasons, but I would personally just get in the habit of disabling developer based features unless you want users to help you debug issues on other devices which isn't common practice in my experience.

网友答案:

The answer is YES.

You can hide them adding some lines to the proguard.cfg file.

-keep class * extends android.app.Activity
-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** e(...);
    public static *** i(...);
}

After the app has been signed no one will be able to read debug, error and info logs. Hope it works.

分享给朋友:
您可能感兴趣的文章:
随机阅读: