输出日志信息是指Android应用

输出日志信息是指Android应用运行时的信息,例如在运行的时候抛出异常,在Eclipse中的Console视图中是不能看到异常信息的。Android应用该如何调试和查看错误信息呢?于是Eclipse中的ADt插件就提供了一个 查看输出日志信息和方便软件工程师、程序员调试的一个试图LogCat。

总结:Android 第六课 查看输出日志信息 - 好有爱 - 什么都不写就更好了
 

 上面有很多信息。

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.

必须要创建一个过滤器,在LogCat视图中,根据tag来查询出当前的应用所输出的信息。

比如要输出www.baidu.com那应该怎么输出呢?

有两种方式:

1.System.out.println(www.baidu.com): 2.Log.i(TAG,www.baidu.com)

前者你可以再LogCat视图tag为System.out中搜索,就能够搜索到你想要的信息。

后者,LogCat视图tag必须为TAG所表示的字符串信息来查询。

 

个人学习后:

    觉得,这个学习很重要,因为以后做开发的话,肯定会用到调试的,这个道理你们都懂的。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值