3

My application has lots of Log.i(); statements added for debugging. Now if such an application need to be uploaded to market

  1. Should these logs be removed, and if yes is there an easy way than manual removal

  2. If not removed, will those logs be coming if the application is run by the user after installing from the market

( i tried to see the logs for some applications and i couldnt see any logs from the applications. I could see only android logs like from activity manager . But i dont see why the logs will not be displayed if they are not removed from the code)

png
  • 4,368
  • 7
  • 69
  • 118

2 Answers2

4

Preetha, the logs will be kept on the phone and any user/developer can check them out by installing apps like Catlog even without using adb! This is a problem as you stand to give unnecessary and at times, confidential data to users/other developers.

Simple way to solve this?

a. Use Proguard to automatically block all logs, more information in this stackoverflow thread

Here you can automatically block all logs at the bytecode level in Proguard

-assumenosideeffects class android.util.Log {
    public static int v(...);
}

The above, for example would remove any verbose logging, more in this thread

b. I use a if(DEBUG) Log.i for all my logs, so that with one change of the boolean DEBUG i can switch on/off all logs

c. A trivial solution: replace all Log.i with //Log.i :)

Community
  • 1
  • 1
Soham
  • 4,940
  • 3
  • 31
  • 48
  • Thanks a lot for the answer . One more doubt . Do i need to install apps like Catlog , if i have eclipse opened, and if i connect my mobile to pC , i can see in the logcat Right ? – png Mar 05 '12 at 08:08
  • Yes, as a developer you don't need to install Catlog, you can see all the logs in logcat on eclipse when the device is connected to the PC. In case your device is not connected to the PC and you want to see the logs on the device itself, you can install the Catlog app on the device and you can see the logs there itself. – Soham Mar 05 '12 at 08:12
  • Will using this method affect line numbers when trying to match up stacktraces? I've seen other posts with this solution and some people said it only affects bytecode so line numbers stay the same, while others say it doesn't. Can you confirm? – Tony Chan Apr 18 '12 at 01:14
2

Yes, a good practice is to remove all the log methods called during testing,

And yes when the user downloads the application it would show all the logs to him/her that you made.

What you can do is Create a static Class with static method in that class,

when ever you want to make a log call simply call that method from anywhere by ClassName.Method

And once you are finished with testing simply COMMENT the Definition in the static method written in the Static class.

Some one Some where
  • 777
  • 1
  • 8
  • 26