Why are Log.d () messages showing up on the device when they shouldn't?

The Android docs state:

The order in terms of verbosity, from least to most, is ERROR, WAR, INFO, DEBUG, VERBIS. Verbose should never be compiled into an application other than during development. Debug logs are compiled but removed at run time. Error, warning and information logs are always saved.

But try it Log.d()

and you will find that it actually still writes Logcat on the real device.

Does anyone know why? Or how can I turn it off?

Thank!

+3


source to share


4 answers


What you see is the expected behavior. Log.d will always be logged and displayed if you are using logcat and connecting a device. Hence, if you don't want debug logs in your production application, disable it. Infact android sdk prompts you to do this. This answer might help you. Do I have to comment on my journal requests when creating my final package?

Andriod sdk says



Disable logging and debugging

Make sure you turn off logging and turn off the debug option before building your application for release. You can disable it by removing calls to log methods in the 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 created in your project.

Additionally, you must remove any Debug trace calls that you added to your code, such as the startMethodTracing () method and stopMethodTracing () calls.

Source

+5


source


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



0


source


If verbose is compiled into dvelopment it would be funny if the debug logs weren't there. So sign your application and try it, I think the debug messages are missing.

-1


source


When a device is connected, it will activate debug mode. I don't think it does the same if the app is launched with the device disabled, although you can't check that ...

-1


source







All Articles