为什么不应该在设备上显示Log.d()消息?

为什么不应该在设备上显示Log.d()消息?,第1张

概述Android文档指出:Theorderintermsofverbosity,fromleasttomostisERROR,WARN,INFO,DEBUG,VERBOSE.Verboseshouldneverbecompiledintoanapplicationexceptduringdevelopment.Debuglogsarecompiledinbutstrippedatruntime.Error,warningand

Android文档指出:

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.

但是尝试执行Log.d(),您会发现它实际上仍在实际设备上记录到Logcat.

有人知道为什么吗?还是如何禁用它?

谢谢!

解决方法:

您所看到的是预期的行为.如果使用logcat并连接设备,则Log.d将始终被记录并可见.因此,如果您不希望在生产应用程序中调试日志,请将其关闭.实际上,AndroID SDK建议您这样做.这样的答案可能也对您有帮助. Should I comment my log calls when creating my final package?

安德里奥·SDK说

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

总结

以上是内存溢出为你收集整理的为什么不应该在设备上显示Log.d()消息?全部内容,希望文章能够帮你解决为什么不应该在设备上显示Log.d()消息?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1085379.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存