Android Log类基本用法
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
TAGconstant 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类基本用法的更多相关文章
- android application类的用法
android application类的用法 Application是android系统Framework提供的一个组件,它是单例模式(singleton),即每个应用只有一个实例,用来存储系统的一 ...
- Log.i()的用法
2011-04-16 09:44 17486人阅读 评论(4) 收藏 举报 androidlayoutbuttonstringencodingeclipse 在调试代码的时候我们需要查看调试信息,那我 ...
- 转:Android Log
在调试代码的时候我们需要查看调试信息,那我们就需要用Android Log类. android.util.Log常用的方法有以下5个:Log.v() Log.d() Log.i() Log.w() 以 ...
- android中Handle类的用法
android中Handle类的用法 当我们在处理下载或是其他需要长时间执行的任务时,如果直接把处理函数放Activity的OnCreate或是OnStart中,会导致执行过程中整个Activity无 ...
- android中Log类的封装
1.为了方便的使用Log打印日志,以及后续方便撤销日志打印,所以对Log类进行封装是一件好事. package market.phone; import android.util.Log; /** * ...
- Android学习笔记Log类输出日志信息
Log类提供的方法 代码示例 .. Log.e(TAG,"[错误信息]"); Log.w(TAG,"[警告信息]"); Log.i(TAG,"[普通信 ...
- android的logcat详细用法
Android日志系统提供了记录和查看系统调试信息的功能.日志都是从各种软件和一些系统的缓冲区中记录下来的,缓冲区可以通过 logcat 命 令来查看和使用. 使用logcat命令 你可以用 logc ...
- Android listview与adapter用法(BaseAdapter + getView)
Android listview与adapter用法http://www.cnblogs.com/zhengbeibei/archive/2013/05/14/3078805.html package ...
- Android开发--IntentService的用法,你错过了什么
Android开发--IntentService的用法,你错过了什么 . 本文链接:https://blog.csdn.net/smbroe/article/details/45009721 Inte ...
随机推荐
- Centos7下面安装eclipse
下载Eclipse压缩包 下载路径 http://mirrors.neusoft.edu.cn/eclipse/technology/epp/downloads/release/luna/SR2/ec ...
- 第三次作业 史浩然 -assassin Talon
- Excel英语成绩单
- 类库文件引用web服务报错解决方法-在 ServiceModel 客户端配置部分中,找不到引用协定的默认终结点元素
由于需求,需要改造原有应用,因原有应用是写在console下面的,现在需要开放至web下, 想到BIZ层应用代码都是一样的,又不想在web下在添加引用,而重复写代码,故将原有的console下的服务和 ...
- solr集群搭建(4.10.2)
配置环境为centos6.8 下载tomcat程序到服务器,并解压启动服务测试 [root@hadoop01 ~]# wget http://apache.claz.org/tomcat/tomcat ...
- BZOJ1014:[JSOI2008]火星人(Splay,hash)
Description 火星人最近研究了一种操作:求一个字串两个后缀的公共前缀.比方说,有这样一个字符串:madamimadam, 我们将这个字符串的各个字符予以标号:序号: 1 2 3 4 5 6 ...
- 简单属性margin和padding
关于margin属性的介绍 margin:20px 上 右 下 左 都是20px margin:20px 40 px 上 下 20px 左 右 40px margin:20px 40px 60px ...
- 新闻cms管理系统(二) ---- 后台登录功能
1.页面准备: (1)前端资源的导入:将准备好的页面添加到项目中,放到Public目录下(公共的页面样式.js.图片等资源) (2)添加登录的视图模板 将登录页面的视图放到Amin>View&g ...
- 在hyper-v中安装centos后配置网络
/etc/sysconfig/network-scripts vi ifcfg-eth0 改为以下配置 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no ...
- 404 Note Found队 Alpha7
目录 组员情况 组员1(组长):胡绪佩 组员2:胡青元 组员3:庄卉 组员4:家灿 组员5:凯琳 组员6:翟丹丹 组员7:何家伟 组员8:政演 组员9:黄鸿杰 组员10:刘一好 组员11:何宇恒 展示 ...