android Log.isLoggable方法的使用

android 动态控制logcat日志开关,通过Log.isLoggable(TAG,level)方法动态控制,
1.添加日志的时候加入判断,
String TAG="Volley";
boolean isDbug=Log.isLoggable(TAG, Log.VERBOSE);
if (isDbug) {
Log.w(TAG, "log");
}
2.通过设置属性值来控制该日志开关。

在pc上,cmd->目录指向adb.exe(D:\android\adt-bundle-windows-x86-20131030\sdk \platform-tools)->adb shell setprop log.tag.Volley VERBOSE 设置该TAG的输出级别为VERBOSE。 则Log.isLoggable("Volley", Log.VERBOSE) level为VERBOSE以上的都返回true,每设置一次,只能用于一部手机没有重启的情况,如果换一部或者重启要重新设置一下;这样的好处是,自己 开发的手机设置一次,都能打印VERBOSE,编译给别的手机就不能打印VERBOSE信息,这样就不用每次正式发布时要把isDbug设置为false
该属性值取值顺序为【V,D,I,W,E,A,S】 A表示最高级别的日志,即assert;S表示Suppress,即停止该日志的输出。

也可以将该属性添加在data/local.prop属性文件中,不同的是,只要存在local.prop,该手机重启与否都一样,可以打印VERBOSE

更多相关文章

  1. android EditText 全面阐述
  2. Android引用资源(resources) vs 引用样式属性(style attribute)语法
  3. ListView点击效果设置
  4. Android基础————UI布局之高级控件详解
  5. android Log.isLoggable步骤的使用
  6. LinearLayout和RelativeLayout 属性对比
  7. 在LinearLayout中嵌套RelativeLayout来设置Button的位置(xml文件)
  8. Android横竖屏总结
  9. 总结EditText,TextView使用的点点滴滴

随机推荐

  1. java.lang.RuntimeException: Unable to
  2. 逆向手机内核,添加调试支持及绕过反调试
  3. Android内置的Action
  4. Android中帧动画在Activity启动时自动运
  5. Android Studio3.0自定义apk输出路径和文
  6. Android 常见对话框
  7. Android开启硬件加速
  8. Android存储之SharePreferences
  9. Android 子控件高度超出父布局的限制
  10. ICS SystemServer之Device Policy