adb是多种用途的工具,该工具可以帮助你你管理设备或模拟器的状态。在android中,adb可以调动LogCat Show View,用来替代Console (android的后台信息显示:包括System.out.println()、e.printStackTrace()不会在console中显示,而需要在LogCat中显示)。Logcat用于观察调试内容,LogCat不支持中文,但是其过滤器功能很好用,System.out.println()是以I级别显示在LogCat中的
Log.v的调试颜色为黑色 的,任何消息都会输出;
Log.d的输出颜色是蓝色的 ,仅输出debug,但他会输出上层的信息,过滤通过DDMS的Logcat标签来选择。
Log.i的输出为绿色 ,一般提示性的消息information,它不会输出Log.v和Log.d的信息,但会显示i、w和e的信息。
Log.w的意思为橙色 ,需要我们注意优化Android代码,同时选择它后还会输出Log.e的信息。
Log.e为红色 ,这些错误就需要我们认真的分析,查看栈的信息了。


在android程序中输出日志,使用android.util.Log 类。该类提供了若干静态方法

Log.v(String tag, String msg);
Log.d(String tag, String msg);
Log.i(String tag, String msg);
Log.w(String tag, String msg);
Log.e(String tag, String msg);

分别对应 Verbose, Debug, Info, Warning, Error。其中tag是一个标识, 可以是任意字符串, 通常可以使用类名+方法名, 主要是用来在查看日志时提供一个筛选条件 。android规范建议VERBOSE,DEBUG信息应当只存在于开发中,最终版本只可以包含INFO, WARN,ERROR这三种日志信息。

日志显示命令行:adb logcat(Run As --> Run Configurations --> Target --> Additional Emulator Command Line Options)。
当执行adb logcat后会以tail方式实时显示出所有的日志信息. 这时候我们通常需要对信息进行过滤,来显示我们需要的信息,这时候我们指定的TAG就派上了用场.
命令行中输入:adb logcat -s x-navi:I
这时将只显示TAG为
x-navi , 级别为I或级别高于I(Warning,Error)的日志信息.


LogCat参明 数说 (感谢javaeye fins网友提供)

Usage: logcat [options] [filterspecs]   options include:     -s              Set default filter to silent.                     Like specifying filterspec '*:s'    -f <filename>   Log to file. Default to stdout     -r [<kbytes>]   Rotate log every kbytes. (16 if unspecified). Requires -f     -n <count>      Sets max number of rotated logs to <count>, default 4    -v <format>     Sets the log print format, where <format> is one of:                       brief process tag thread raw time long      -c              clear (flush) the entire log and exit     -d              dump the log and then exit (don't block)     -g              get the size of the log's ring buffer and exit     -b <buffer>     request alternate ring buffer, defaults to 'main'  filterspecs are a series of     <tag>[:priority]     where <tag> is a log component tag (or * for all) and priority is:     V    Verbose     D    Debug     I    Info     W    Warn     E    Error     F    Fatal     S    Silent (supress all output)     '*' means '*:d' and <tag> by itself means <tag>:v     If not specified on the commandline, filterspec is set from ANDROID_LOG_TAG   If no filterspec is found, filter defaults to '*:I'    If not specified with -v, format is set from ANDROID_PRINTF_LOG   or defaults to "brief"  

更多相关文章

  1. android软键盘的显示后隐藏
  2. Android(安卓)关于EditText文字的显示问题 和属性
  3. android 下载网络pdf文件后并显示
  4. gravity和android:layout_gravity区别
  5. Android开机动画bootanimation.zip
  6. Android之TextView------属性大全
  7. Android系统信息获取 之四:系统语言信息获取
  8. Android(安卓): 如何在WebView显示的页面中查找内容
  9. Android中级教程之----Log图文详解(Log.v,Log.d,Log.i,Log.w,Log

随机推荐

  1. Android(安卓)自定义View总结 —— Layou
  2. Android中从网络获取数据的方法
  3. Android(安卓)相机开发 Camera-附带扫码
  4. Android(安卓)Cocos2d-x游戏集成友盟社会
  5. Android工程打包(含React Native工程)
  6. Android(安卓)平台综述
  7. Android(安卓)FFmpeg在Windows上编译的版
  8. Android中常用的颜色
  9. android studio 提示"Gradle project syn
  10. 【爬坑记录】ncnn移植到Android上出现的