1

When an app is compiled, what is the minimum priority which is packaged in the APK? The documentation for android.util.Log states that

Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.

Does this imply that different levels of verbosity are handled differently at compile-time and at runtime? What is this different handling? Furthermore, is Log.d() preferred over Log.v() for general "somemethod() called." messages and why?

gobernador
  • 5,659
  • 3
  • 32
  • 51
  • Google recommends removing Log statements prior to building a release .apk. – Joel Skrepnek Mar 04 '12 at 06:19
  • print in DEBUG mode not in VERBOSE http://developer.android.com/reference/android/util/Log.html – Nir Alfasi Mar 04 '12 at 06:20
  • 1
    @alfasin What does it mean when they say "Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept."? – gobernador Mar 04 '12 at 19:08

1 Answers1

0

When it says "Verbose should never be compiled into an application except during development," that means you, the developer, should take them out prior to release, not that the compiler will throw them out.

The normal way I ensure my logs don't make it to release is with a helper function:

public static void log(String txt)
{
    if(!isRelease)
        Log.d("AppName", txt);
}

It relieves me of typing the tag name/variable every time, and all I have to do to remove them all is change one static variable in code, isRelease.

Geobits
  • 22,218
  • 6
  • 59
  • 103
  • This only answers part of the question. The question asks are different levels of verbosity handled differently at compile-time and at runtime. Should some be left and others not? – gobernador Jul 02 '12 at 15:26
  • Runtime I'm not sure, but as far as I know none are removed at compile. You can configure ProGuard, however, to remove any level you'd like: http://stackoverflow.com/a/2019002/752320 . In general, I don't see a good reason to leave either debug or verbose in the released version. I wouldn't rely on the system removing them at runtime when I can easily do so myself. – Geobits Jul 02 '12 at 15:37