My question is simple. Should I remove Log.d/e/i/v and e.printStackTrace instructions before uploading my app to Android market?
-
Look at the exact duplicate here http://stackoverflow.com/questions/4958860/should-i-comment-my-log-calls-when-creating-my-final-package – rfsk2010 Mar 05 '12 at 09:05
8 Answers
If possible yes, Its a good application development practice, But proper handle of e.printStack
is necessary to prevent your application force close from un necessary exception. For this you can use Log.e(TAG, e.toString());
in all catch block. This will be keep some necessary information about your application behavior and you can also easily get information about any force-close or exception for your application.

- 108,599
- 23
- 164
- 151
Log.debug instructions automatically gets remvoed when you obsufucate your application. See link:
Android Proguard, removing all Log statements and merging packages
OfCource you should, especially if your application relies a lot on performance (eg a game having fast frame rate), otherwise the printing of logs eats up a lot of performance The correct way to do this is to have a flag something like isLoggable, which if set to false wont print the logs.

- 6,328
- 12
- 52
- 84
I just create my own Log class and build wrapper methods for the android.util.Log methods, which check BuildConfig.DEBUG
before writing the log.

- 6,629
- 3
- 30
- 35
To remove calls to the Log class add the following to the proguard-rules file:
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}

- 2,702
- 1
- 19
- 13
It really depends on the lifecycle of the application after it gets released to the market.
If you cannot trust your users to provide detailed bug reports (generally speaking, with engineering-related apps you can hope that some users would have the acumen to submit detailed crash report), then there is no reason to bloat the Android Log.
On the other hand, some bugs are heisenbugs and might disappear after you add logging statements, making them really difficult to find.
It's really a matter of taste - I provide a build-time switch that includes them in debug builds, but not in release builds. And I usually wait until the app is past beta to disable debug log completely.

- 6,195
- 5
- 44
- 95
I don't know if you must delete it. If I upload a project into the market, I got 2 version of the same app.
- with println and logs
- without println and logs
removing them will always make the app go a little quicker (very little).

- 3,616
- 5
- 29
- 52
You can take a look here, they recommend that you disable the logging:
Make sure you deactivate logging and disable the debugging option before you build your application for release. You can deactivate logging by removing calls to Log methods in your source files.
However, you should keep some logging, such as printing the stack trace on exceptions etc. as you'll probably have loads of trouble debugging possible crashes later on if you remove them.

- 31,598
- 14
- 77
- 90