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. December 17th 2016 Week 51st Saturday

    Great minds have purpose, others only have wishes. 杰出的人有着目标,其他人只拥有愿望. Are you clear about the differ ...

  2. 初进MFC的世界,太奇妙。第六次作业----未完待续

    又一次的迁徙.我希望能够早些抵达. 第六次作业-未完待续!图形界面,计算器文件 本次的作业是给自己的计算器加一个可视化的窗口,我开始也是很激动和憧憬的,看了很多的界面库,发现并没有想象的那么简单,因为 ...

  3. 初探BeEF

    1.什么是BeEF? 就是 The Browser Exploitation Framework 的缩写,意在通过一些手段,控制对方的浏览器. 里面集成了很多模块,能够获取很多东西,有cookie,浏 ...

  4. win10里如何在中文输入法里添加美式键盘

    在控制面板打开“时钟.语言和区域”设置界面,选中“语言”设置  “语言”设置里点击“添加语言” 在添加语言设置里选择“英语”,并点击“打开”按钮,在“区域变量”设置页面里选择“英语(美国)” ,并点击 ...

  5. 《OpenGL编程指南第七版》学习——编译时提示“error C2381: “exit” : 重定义;__declspec(noreturn) 不同”错误的解决办法

    解决办法一. #if defined(_WIN32) # ifndef GLUT_BUILDING_LIBextern _CRTIMP void __cdecl exit(int); 上面是glut. ...

  6. nginx中文文档

    http://www.nginx.cn/doc/ LNMP :https://lnmp.org/faq/lnmp-vhost-add-howto.html 配置详解 配置详解2

  7. ASP.Net GridView 基础 绑定字段

    通过以前的学习,我们实现了效果如下: 现在我想修改显示/隐藏部分列,有两种做法: 一.在配置数据源的时候不是有查询哪些字段的吗,去除不需要的字段,重新绑定. 二.就是直接编辑列 下面是分析每种字段类型 ...

  8. Oracle条件查询

    Oracle条件查询 参考网址:http://www.oraclejsq.com/article/010100259.html Oracle条件查询时经常使用=.IN.LIKE.BETWEEN...A ...

  9. iOS 推送功能打包后获取不到deviceToken

    公司项目用ionic3构建, 用了极光推送插件(cordova-plugin-jpush). 开发时一切将各种Bundle Id, 推送证书等都绑定完测试一切正常. 可是要给测试人员打Ad-Hoc包时 ...

  10. iOS 中系统与 SDK 版本检测

    一.编译时检测 1. 判断 SDK 是否是某个版本或更高版本 ifdef __IPHONE_11_0 2.判断当前需要支持的最低版本 __IPHONE_OS_VERSION_MIN_REQUIRED ...