3

Android docs indicate:

The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. 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.

But try to do a Log.d() and you'll find it's actually still recording to Logcat on a real device.

Does anyone know why? Or how to disable it?

Thank you!

lucian.pantelimon
  • 3,673
  • 4
  • 29
  • 46
Stephan Tual
  • 2,617
  • 3
  • 27
  • 49

4 Answers4

7

What you are seeing is expected behaviour. Log.d will always be logged and visible if you use logcat and connect the device. Hence if you dont want debug logs in production app , turn it off. Infact android sdk suggests you do that. This SO answer might help you as well. Should I comment my log calls when creating my final package?

Andriod sdk says

Turn off logging and debugging

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. You can disable debugging by removing the android:debuggable attribute from the tag in your manifest file, or by setting the android:debuggable attribute to false in your manifest file. Also, remove any log files or static test files that were created in your project.

Also, you should remove all Debug tracing calls that you added to your code, such as startMethodTracing() and stopMethodTracing() method calls.

Source

Community
  • 1
  • 1
rfsk2010
  • 8,571
  • 4
  • 32
  • 46
0

You should encapsulate logging in your own class and enable/disable special types of logs when you need.

Alex Klimashevsky
  • 2,457
  • 3
  • 26
  • 58
  • 1
    Good idea, rfsk2010 is accurate in his answer but you're correct as well in that debug message when removed through the manifest flag might be useful as some point later (maybe to ask a user to enable logging then email the said log). Using a separate class seems the way to go, an example is available here: http://code.google.com/p/teddsdroidtools/source/browse/trunk/teddsdroidtools/src/tss/droidtools/BaseActivity.java – Stephan Tual Apr 05 '12 at 11:03
-1

if verbose is compiled in dvelopment, it would be funny if debug logs not. So signe your app and give it a try, i think the debug messages are missing then.

Fabian Knapp
  • 1,342
  • 13
  • 27
-1

When you plug your device it activates the debug mode. I don't think it's doing the same if the app run with the device unplugged, though you can not check that...

Philippe
  • 103
  • 1
  • 7