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?
Share your experience.
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");
You can delete journal entries during assembly using the obfuscation tool. See here for more details .
, log4j android. lo4gj slf4j. LogCat. . android-logging-log4j log4j android
. - LumberJack. Jitpack gradle ( README.md).
README.md
LumberJack (, LumberJack.d() Log.d() ..)
LumberJack.d()
Log.d()
"LumberJack". .
LumberJack.setLogLevel(). , LogLevel LogLevel.None.
LumberJack.setLogLevel()
LogLevel
LogLevel.None
LumberJack.setLogLevel(LogLevel.None);
, -, .
logcat .
. , , , , , Log.d().
Android, log4j. , , .
, (, toString ), .
if (Log.isDebugEnabled()) { Log.Debug(bigCollection.toString()); }
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 }