Logging strategy

I am going to end my android application. In the end, I found that I use a bunch of logging statements, for example:

Log.d(TAG, "Blah-blah");

The question is: for product release, what should I do with them?

  • Just comment / record journal entries
  • Do anything even harder? As before, I used the properties of Log4J or

Share your experience.

+5
source share
7 answers

I do this so that the compiler deletes all entries if DEBUG is false:

if (Constant.DEBUG) Log.d(TAG, "mein gott, state is roflcopter");
0
source

You can delete journal entries during assembly using the obfuscation tool. See here for more details .

+4
source

, log4j android. lo4gj slf4j. LogCat. . android-logging-log4j log4j android

+1

. - LumberJack. Jitpack gradle ( README.md).

LumberJack (, LumberJack.d() Log.d() ..)

"LumberJack". .

LumberJack.setLogLevel(). , LogLevel LogLevel.None.

LumberJack.setLogLevel(LogLevel.None);

, -, .

logcat .

+1

. , , , , , Log.d().

0

Android, log4j. , , .

, (, toString ), .

if (Log.isDebugEnabled()) {
   Log.Debug(bigCollection.toString());
}
0

If you do not want to register something in the Android version, you can use the automatically created BuildConfig. More on this here: https://developer.android.com/studio/build/gradle-tips.html . You can also read more information in this question: BuildConfig file in android - Purpose and features .

So, in the code you just write something like this:

if (BuildConfig.DEBUG) {
    //your code just for development goes here
}
0
source

All Articles