Log类介绍:

API for sending log output.Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods.

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.

Tip:

A good convention is to declare a TAG constant in your class:private static final String TAG = "MyActivity"; and use that in subsequent calls to the log methods.

Tip:

Don't forget that when you make a call like Log.v(TAG, "index=" + i); that when you're building the string to pass into Log.d, the compiler uses a StringBuilder and at least three allocations occur: the StringBuilder itself, the buffer, and the String object.

Realistically, there is also another buffer allocation and copy, and even more pressure on the gc. That means that if your log message is filtered out, you might be doing significant work and incurring significant overhead.

Log类位于android.util包中,里面都是一些静态方法。

默认的输出使用Log类就可以了。

Log类的几个重要方法

1. Log.v()

v,即Verbose,中文:详细的,输出最最普通的信息。

两重载:

 public static int v(String tag, String msg)
public static int v(String tag, String msg, Throwable tr)

tag为标签,一般为调用类的名称,msg为输出信息,其他输出方法类似。

2.Log.d()

d,即Debug,输出调试信息。

3.Log.i()

i,即Information,输出一般信息。

4.Log.w()

w,即Warning,警告信息。

5.Log.e()

e,即Error,输出错误信息。

Android Log类基本用法的更多相关文章

  1. android application类的用法

    android application类的用法 Application是android系统Framework提供的一个组件,它是单例模式(singleton),即每个应用只有一个实例,用来存储系统的一 ...

  2. Log.i()的用法

    2011-04-16 09:44 17486人阅读 评论(4) 收藏 举报 androidlayoutbuttonstringencodingeclipse 在调试代码的时候我们需要查看调试信息,那我 ...

  3. 转:Android Log

    在调试代码的时候我们需要查看调试信息,那我们就需要用Android Log类. android.util.Log常用的方法有以下5个:Log.v() Log.d() Log.i() Log.w() 以 ...

  4. android中Handle类的用法

    android中Handle类的用法 当我们在处理下载或是其他需要长时间执行的任务时,如果直接把处理函数放Activity的OnCreate或是OnStart中,会导致执行过程中整个Activity无 ...

  5. android中Log类的封装

    1.为了方便的使用Log打印日志,以及后续方便撤销日志打印,所以对Log类进行封装是一件好事. package market.phone; import android.util.Log; /** * ...

  6. Android学习笔记Log类输出日志信息

    Log类提供的方法 代码示例 .. Log.e(TAG,"[错误信息]"); Log.w(TAG,"[警告信息]"); Log.i(TAG,"[普通信 ...

  7. android的logcat详细用法

    Android日志系统提供了记录和查看系统调试信息的功能.日志都是从各种软件和一些系统的缓冲区中记录下来的,缓冲区可以通过 logcat 命 令来查看和使用. 使用logcat命令 你可以用 logc ...

  8. Android listview与adapter用法(BaseAdapter + getView)

    Android listview与adapter用法http://www.cnblogs.com/zhengbeibei/archive/2013/05/14/3078805.html package ...

  9. Android开发--IntentService的用法,你错过了什么

    Android开发--IntentService的用法,你错过了什么 . 本文链接:https://blog.csdn.net/smbroe/article/details/45009721 Inte ...

随机推荐

  1. 编写VBA宏生成页面

    概述 依据详细设计中表设计,借用excel宏编写VBA生成页面. 特色 高定制.高效率.兼容所有生成要求.不依赖低耦合.任意Sheet适用 缺陷 不支持批量Sheet页生成 VBA源码 Sub lis ...

  2. 安装office2016和激活。

    严重声明:条件宽裕的同学可以购买正版.请大家多多支持正版. 自己手贱,原本在电脑win10系统上安装的正版office被误删了,联系了客服人员,但是自己的微软账号也忘记了.好想下载个正版的.自己在网上 ...

  3. December 05th 2016 Week 50th Monday

    Today is my birthday and I have totally refreshed. Knowing yourself is the beginning of all wisdom. ...

  4. [原]Ubuntu 下安装apache+PHP

    1.安装apache2 sudo apt-get install apache2 运行如下命令重启:sudo /etc/init.d/apache2 restart 在浏览器里输入http://loc ...

  5. BeautifulSoup使用注意事项

    BeautifulSoup使用注意事项 BeautifulSoup是一个可以从HTML或XML文件中提取数据的Python库.它能够通过你喜欢的转换器实现惯用的文档导航,查找,修改文档的方式.Beau ...

  6. 3171. [TJOI2013]循环格【费用流】

    Description 一个循环格就是一个矩阵,其中所有元素为箭头,指向相邻四个格子.每个元素有一个坐标(行,列),其中左上角元素坐标为(0,0).给定一个起始位置(r,c) ,你可以沿着箭头防线在格 ...

  7. Odoo中的向导

    转载请注明原文地址:https://www.cnblogs.com/cnodoo/p/9281320.html 一:向导及其效果 向导类似于弹窗,用于接收用户的输入,然后作出相应的处理. 二:定义向导 ...

  8. ionic 入门创建第一个应用demo

    一.ionic卸载 1.清除旧版本的ionic框架 npm uninstall -g ionic npm uninstall -g cordova npm cache clear npm cache ...

  9. Week7:SVM难点记录

    1.函数dataset3Params(),如何计算模型估计偏差的? model=svmTrain(X,y,c_array,@(x1,x2)gaussianKernel(x1,x2,sigma_arra ...

  10. PAT——1075. 链表元素分类(25)

    给定一个单链表,请编写程序将链表元素进行分类排列,使得所有负值元素都排在非负值元素的前面,而[0, K]区间内的元素都排在大于K的元素前面.但每一类内部元素的顺序是不能改变的.例如:给定链表为 18→ ...