Android中Log的输出有如下几种:

Log.v(String tag, String msg);        //VERBOSE
Log.d(String tag, String msg);       //DEBUG
Log.i(String tag, String msg);        //INFO
Log.w(String tag, String msg);     //WARN
Log.e(String tag, String msg);      //ERROR

以上log的级别依次升高,VERBOSE DEBUG信息应当只存在于开发中,INFO,WARN,ERROR这三种log将出现在发布版本中。

对于JAVA类中,可以声明一个字符串常量TAG,Logcat可以根据他来区分不同的log,例如在WindowsManagerService.java的类中,定义如下所示:
static final Sting TAG = "WindowManager"
需要打log的地方
Log.v(TAG, "Figuring out where to add app window" + client.asBinder() + "(token=" + token + ")");

logcat使用方法如下所示:

logcat [options] [filterspecs]
option "-s" 用来设置过滤器,格式是这样的 <tag>[:priority]
其中 <tag> 表示log的component, tag (或者使用 * 表示所有) ,priority如下所示:
V Verbose
D Debug
I Info
W Warn
E Error
F Fatal
S Silent

例:
logcat -s *:s  不打任何log
logcat -s WindowMnager:V   <-- 打印WindowManagerService 中 Verbose 信息
如果在eclipse中查看Android log 输出,也就是logcat信息,可以 选择Windows > Show View > Other... > Android > LogCat。


logcat的参数说明:
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"

Android中Log机制详解的更多相关文章

  1. Android事件传递机制详解及最新源码分析——ViewGroup篇

    版权声明:本文出自汪磊的博客,转载请务必注明出处. 在上一篇<Android事件传递机制详解及最新源码分析--View篇>中,详细讲解了View事件的传递机制,没掌握或者掌握不扎实的小伙伴 ...

  2. Android中Service(服务)详解

    http://blog.csdn.net/ryantang03/article/details/7770939 Android中Service(服务)详解 标签: serviceandroidappl ...

  3. Android中mesure过程详解

    我们在编写layout的xml文件时会碰到layout_width和layout_height两个属性,对于这两个属性我们有三种选择:赋值成具体的数值,match_parent或者wrap_conte ...

  4. Android中Intent组件详解

    Intent是不同组件之间相互通讯的纽带,封装了不同组件之间通讯的条件.Intent本身是定义为一个类别(Class),一个Intent对象表达一个目的(Goal)或期望(Expectation),叙 ...

  5. Android中的动画详解系列【4】——Activity之间切换动画

    前面介绍了Android中的逐帧动画和补间动画,并实现了简单的自定义动画,这一篇我们来看看如何将Android中的动画运用到实际开发中的一个场景--Activity之间跳转动画. 一.定义动画资源 如 ...

  6. Android事件分发机制详解

    事件分发机制详解 一.基础知识介绍 1.经常用的事件有:MotionEvent.ACTION_DOWN,MotionEvent.ACTION_MOVE,MotionEvent.ACTION_UP等 2 ...

  7. RxJava在Android中使用场景详解

    RxJava 系列文章 <一,RxJava create操作符的用法和源码分析> <二,RxJava map操作符用法详解> <三,RxJava flatMap操作符用法 ...

  8. Android开发——Android的消息机制详解

    )子线程默认是没有Looper的,Handler创建前,必须手动创建,否则会报错.通过Looper.prepare()即可为当前线程创建一个Looper,并通过Looper.loop()来开启消息循环 ...

  9. Android中的Service详解

    今天我们就来介绍一下Android中的四大组件中的服务Service,说到Service, 它分为本地服务和远程服务:区分这两种服务就是看客户端和服务端是否在同一个进程中,本地服务是在同一进程中的,远 ...

随机推荐

  1. ★ Maven的坑,tomcat插件6 不能与jdk8一起使用

    Maven 集成Tomcat7插件 maven WEB项目启动没问题访问页面就报错:org.apache.jasper.JasperException: Unable to compile class ...

  2. 打开Win7休眠模式和离开模式的方法

    打开Win7休眠模式和离开模式的方法 ●启动休眠模式 从开始菜单中找到“附件→命令提示符”,手工输入如下命令:powercfg -a,从这里可以清楚的看到,计算机是支持休眠的,显示“尚未启用休眠&qu ...

  3. kettle的报错解决机制

    在kettle执行的过程中,如果遇到错误,kettle会停止运行.在某些时候,并不希望kettle停止运行,这时候可以使用错误处理(Step Error Handling).错误处理允许你配置一个步骤 ...

  4. PHP框架之ThinkPHP项目CMS内容管理系统源码及开发手册视频

    http://download.csdn.net/download/duguqing/4203042

  5. sdi 采集卡---环视频拼接直播方案

    http://www.upano.cn/# 360度无死角直播1080p 30fps http://search.jd.com/Search?keyword=sdi%E9%87%87%E9%9B%86 ...

  6. seqtk 的安装和使用

    seqtk 是一款针对fasta/fastq 文件进行处理的小程序,有很多的功能,速度很快,很方便: 源代码:https://github.com/lh3/seqtk 安装: git clone ht ...

  7. poj 3414 Pots(广搜BFS+路径输出)

    转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents 题目链接:id=3414">http://poj.org/probl ...

  8. gradle教程 [原创](eclipse/ADT下 非插件 非Android Studio/AS)纯手打 第三篇:gradle完整的实战

    上两篇的地址 安装配置 http://www.cnblogs.com/uncle2000/p/4276833.html 简单实战 http://www.cnblogs.com/uncle2000/p/ ...

  9. electron-利用node开发桌面应用

    简介 web前端语言的发展有目共睹, 从原来的pc web, 到后来的mobile SAP, 再到 nodejs,全站工程师应运而生. js快速而且稳健的发展让人不得不重视, 相应的前端开发人员的地位 ...

  10. zookeeper命令行

    ZooKeeper -server host:port cmd args stat path [watch] set path data [version] ls path [watch] delqu ...