我想知道如果我发布这样的应用程序,用户是否会看到我放入的所有调试语句?我是否需要做一些特别的事情,以便即使用户连接’adb logcat’,用户也看不到调试日志?
谢谢.
解决方法 考虑使用它: isLoggable()Checks to see whether or not a log for the specifIEd tag is loggable at the specifIEd level. The default level of any tag is set to INFO. This means that any level above and including INFO will be logged. Before you make any calls to a logging method you should check to see if your tag should be logged. You can change the default level by setting a system property:
setprop log.tag.<YOUR_LOG_TAG> <LEVEL>
Where level is either VERBOSE,DEBUG,INFO,WARN,ERROR,ASSERT,or SUPPRESS. SUPPRESS will turn off all logging for your tag. You can also create a local.prop file that with the following in it:log.tag.<YOUR_LOG_TAG>=<LEVEL>
and place that in/data/local.prop
就个人而言,我会删除调试日志并使用Proguard保留错误日志.
最好像这样包装它:
public class MyLog {public static voID d(String tag,String msg) { if (Log.isLoggable(tag,Log.DEBUG)) { Log.d(tag,msg);}}public static voID i(String tag,String msg) { if (Log.isLoggable(tag,Log.INFO)) { Log.i(tag,msg);}} // and so on...
您可以设置日志级别by issuing an adb command
总结以上是内存溢出为你收集整理的android – 在我的代码中使用Log.d()或Log.e()全部内容,希望文章能够帮你解决android – 在我的代码中使用Log.d()或Log.e()所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)