欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

logcat use

程序员文章站 2023-08-18 10:34:40
将已经存在的工程导入到eclipse步骤: ①:首先复制当前工程所在的路径。 ②:然后在eclipse,右键->Import->General->Existing Projects into Workspace->将复制的路径黏贴进去->Browser->Copy projects into wor ......

将已经存在的工程导入到eclipse步骤:

①:首先复制当前工程所在的路径。

②:然后在eclipse,右键->import->general->existing projects into workspace->将复制的路径黏贴进去->browser->copy projects into workspace->finish。

 1 package com.itheima.logcat;
 2 
 3 import android.os.bundle;
 4 import android.app.activity;
 5 import android.util.log;
 6 import android.view.menu;
 7 
 8 public class mainactivity extends activity {
 9 
10     private static final string tag = "mainactivity";
11 
12     @override
13     protected void oncreate(bundle savedinstancestate) {
14         super.oncreate(savedinstancestate);
15         setcontentview(r.layout.activity_main);
16         
17         log.v(tag, "我是v级别"); 对应的是蓝色
18         log.i(tag, "我是i级别"); 绿色
19         log.d(tag, "我是d级别"); 黑色
20         log.w(tag, "我是w级别"); 黄色
21         log.e(tag, "我是e级别"); 红色
22     }
23 
24     @override
25     public boolean oncreateoptionsmenu(menu menu) {
26         // inflate the menu; this adds items to the action bar if it is present.
27         getmenuinflater().inflate(r.menu.main, menu);
28         return true;
29     }
30 
31 }

解读 1 log.v(tag, "我是v级别"); 

tag used to identify the source of a log message. it usually identifies the class or activity where the log call occurs.(用于标识日志消息的源。它通常标识日志调用发生的类或活动。)

msg the message you would like logged.(您希望记录的消息。)

如何快速的过滤出我自己打印的日志信息呢?

可以通过左边的filters过滤器。 通过tag来过滤。