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 ...
随机推荐
- Visual Studio 2017 连接Oracle
VS 2017 连接 Oracle 12 因为Visual Studio自带的数据文件已经不能支持超过10g以上的了,所以需要另外 下载插件 本机环境 宿主机的环境:win7,Visual Studi ...
- ASP.NET Core 使用 SQLite 教程,EF SQLite教程,修改模型更新数据库,适合初学者看懂详细、简单教程
SQLIte 操作方便,简单小巧,这里笔者就不再过多介绍,感兴趣可以到以下博文 https://blog.csdn.net/qq_31930499/article/details/80420246 文 ...
- Spark 2.x 中 Sort-Based Shuffle 产生的内幕
本课主题 Sorted-Based Shuffle 的诞生和介绍 Shuffle 中六大令人费解的问题 Sorted-Based Shuffle 的排序和源码鉴赏 Shuffle 在运行时的内存管理 ...
- 【RabbitMQ】3、工作队列模式(work模式)
上一篇博客的作为rabbitMQ的入门程序,也是简单队列模式,一个生产者,一个消费者,今天这篇博客介绍work模式,一个生产者,多个消费者,下面的例子模拟两个消费者的情况. 图示: 一 ...
- ZOJ-3278 8G Island---二分第k大
题目链接: https://cn.vjudge.net/problem/ZOJ-3278 题目大意: 给出两个数列A和B,长度分别为N,M (1<=N, M<=10^5, 1<=Ai ...
- VMware Harbor 学习
Harbor简介 Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,通过添加一些企业必需的功能特性,例如安全.标识和管理等,扩展了开源Docker Distributio ...
- Xiaocms验证码绕过分析
事实证明这套程序验证码没有办法存在绕过.具体分析在t00ls上.但是这套程序获取验证码的逻辑是存在问题的,思路是可以借鉴的. 第一次请求后台是,红线位置是请求验证码的url. 当我们第一次请求时,也就 ...
- svn .externals 属性
问:如下自定下载关联模块呢? 答:第一步: 编辑svn.externals文本,如下所示 dir/moduel_name URL/module dir/moduel_name URL/module 第 ...
- git地址
登录地址:https://git.oschina.net/signup API地址:http://git.oschina.net/progit/
- 404 Note Found 队-需求报告
目录 组队后的团队项目的整体计划安排 项目logo及思维导图 项目logo 思维导图 产品思维导图 产品思维导图-引导 产品思维导图-后端数据处理.存储 产品思维导图-短信识别 产品思维导图-智能分析 ...