如何使用 adb logcat 过滤进程查看某个进程的输出日志

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
您的访问请求被拒绝 403 Forbidden - ITeye技术社区
您的访问请求被拒绝
亲爱的会员,您的IP地址所在网段被ITeye拒绝服务,这可能是以下两种情况导致:
一、您所在的网段内有网络爬虫大量抓取ITeye网页,为保证其他人流畅的访问ITeye,该网段被ITeye拒绝
二、您通过某个代理服务器访问ITeye网站,该代理服务器被网络爬虫利用,大量抓取ITeye网页
请您点击按钮解除封锁&温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
这里没有把内核调试信息的级别转换成Androind的LOG级别,entry-&entry.msg[0] = ANDROID_LOG_INFO;使用了ANDROID_LOG_INFO级别,进程ID用了当前的进程ID。
然后就可以使用logcat来抓取kernel的log了!
阅读(2281)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'android adb logcat打印内核调试信息',
blogAbstract:'转自:http://blueredfield./blog/static// http://blog.csdn.net/skywalkzf/article/details/6733944 1、在默认情况下,adb logcat只能显示应用程序的调试信息,我把logcat.cpp修改了一下,让它同时可以打印内核调试信息:
system/core/logcat/logcat.cpp
static void readLogLines(int logfd) { &&& char buffer[256] = {0}; &&& while (1) { &',
blogTag:'',
blogUrl:'blog/static/1',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:1,
permalink:'blog/static/1',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'0',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}如何过滤 adb logcat 命令的输出_百度知道logcat命令使用方法和查看android系统日志缓冲区内容的方法
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了logcat命令使用方法和查看android系统日志缓冲区内容的方法,需要的朋友可以参考下
*注:可以用 adb logcat & 路径/文件名 来保存,此命令执行之时起的全部日志信息到一个文件里,ctrl + C 结束日志输出;后面不加 & 路径/文件名 的话,则在 stdout (终端窗口)中输出!例如:$ adb logcat -v long Checkin *:S & ~/桌面/log.txt
一、在 Java 与 C 语言中输出日志:1) Java 代码在程序中输出日志, 使用 android.util.Log 类的以下 5 个方法:&& Log.v()、Log.d()、Log.i()、Log.w()、Log.e()。&& 分对应 Verbose、Debug、INFO、Warn、Error 的首字母。&& 例如:Log.i( "类::函数名", "日期_时间_源码文件名_行号_日志信息内容" );
2) C 代码在程序中输出日志,使用 log 的 API 函数:&& __android_log_write( 日志类型宏,日志标签字符串,日志令牌内容字符串 );&& 需要:1. Android.mk 中添加 LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog&&    2. *.c 中添加 #include &android/log.h&&&    3. 日志类型宏有: 代码如下:&&&&&&& // Android log priority values, in ascending priority order.&&&&&&& typedef enum android_LogPriority {&&&&&&&&&&& ANDROID_LOG_UNKNOWN = 0,&&&&&&&&&&& // only for SetMinPriority() &&&&&&&&&&& ANDROID_LOG_DEFAULT,&&&&&&&&&&& ANDROID_LOG_VERBOSE,&&&&&&&&&&& ANDROID_LOG_DEBUG,&&&&&&&&&&& ANDROID_LOG_INFO,&&&&&&&&&&& ANDROID_LOG_WARN,&&&&&&&&&&& ANDROID_LOG_ERROR,&&&&&&&&&&& ANDROID_LOG_FATAL,&&&&&&&&&&& // only for SetMinPriority(); must be last &&&&&&&&&&& ANDROID_LOG_SILENT,&&&&&&& } android_LogP二、logcat 使用方法:&&&&& Usage: logcat [options] [filterspecs]用法:& logcat [选项] [过滤说明]
options include:选项包含:& -s&&&&&&&&&&&&& Set default filter to silent.&&&&&&&&&&&&&&&&& Like specifying filterspec '*:S'&&&&&&&&&&&&&&&&& 设置默认过滤为无声的。&&&&&&&&&&&&&&&&& 像指定过滤说明为 *:S ,见下面 过滤说明 部份详述& -f &filename&&& Log to file. &&&&&&&&&&&&&&&&& Default to stdout&&&&&&&&&&&&&&&&& 输出日志到文件。&&&&&&&&&&&&&&&&& 默认为 stdout & -r [&kbytes&]&& Rotate log every kbytes. &&&&&&&&&&&&&&&&& (16 if unspecified). &&&&&&&&&&&&&&&&& Requires -f&&&&&&&&&&&&&&&&& 设置环形日志缓冲区的kbytes。&&&&&&&&&&&&&&&&& 默认值为16。&&&&&&&&&&&&&&&&& 需要和 -f 选项一起使用& -n &count&&&&&& Sets max number of rotated logs to &count&, default 4&&&&&&&&&&&&&&&&& 设置环形日志缓冲区的最大数目,默认值是4,需要和 -r 选项一起使用& -v &format&&&&& Sets the log print format, where &format& is one of:&&&&&&&&&&&&&&&&& 设置 log 的打印格式,& 格式有如下主要7种:(不能组合使用)
&&&&&&&&&&&&&&&&& brief &&&&&&&&&&&&&&&&& process &&&&&&&&&&&&&&&&& tag &&&&&&&&&&&&&&&&& thread &&&&&&&&&&&&&&&&& raw &&&&&&&&&&&&&&&&& time &&&&&&&&&&&&&&&&& threadtime &&&&&&&&&&&&&&&&& long
& -c&&&&&&&&&&&&& clear (flush) the entire log and exit&&&&&&&&&&&&&&&&& 清除所有 log 并退出& -d&&&&&&&&&&&&& dump the log and then exit (don't block)&&&&&&&&&&&&&&&&& 得到所有log并退出且不阻塞& -t &count&&&&&& print only the most recent &count& lines (implies -d)&&&&&&&&&&&&&&&&& 仅打印最近的由参数 count 指出的行数(必然包含 -d)& -g&&&&&&&&&&&&& get the size of the log's ring buffer and exit&&&&&&&&&&&&&&&&& 得到环形缓冲区的大小并退出& -b &buffer&&&&& Request alternate ring buffer, 'main', 'system', 'radio' or 'events'.&&&&&&&&&&&&&&&&& Multiple -b parameters are allowed and the results are interleaved. &&&&&&&&&&&&&&&&& The default is -b main -b system.&&&&&&&&&&&&&&&&& 请求供替换的环形缓冲区,如:main,system,radio,events。&&&&&&&&&&&&&&&&& 多个 -b 参数是被允许,并且结果是交错输出的。&&&&&&&&&&&&&&&&& -b main -b system 是默认的。& -B&&&&&&&&&&&&& output the log in binary&&&&&&&&&&&&&&&&& 输出 log 到二进制文件中。filterspecs are a series of &tag&[:priority]过滤说明是一系列 &tag&[:priority]
where &tag& is a log component tag (or * for all) and priority is:tag 是 eclipse 中 logcat 图形界面中 Tag 的内容(或者有 * 表示全部),它之后的冒号(:)后面跟优先级:&&& 日志类型标识符(优先级由低到高排列):&&& 1. V — Verbose 详细的 &- 最低优先权&&& 2. D — Debug&& 调试&&& 3. I — Info&&& 消息&&& 4. W — Warn&&& 警告&&& 5. E — Error&& 错误&&& 6. F — Fatal&& 致命的&&& 7. S — Silent& 无声的 &- 最高优先权
'*' means '*:d' and &tag& by itself means &tag&:v* 意味着 *:d 且 单孤地 tag 意味着 tag:V
If not specified on the commandline, filterspec is set from ANDROID_LOG_TAGS.如果在命令行上没有详细说明,过滤规格即是 ANDROID_LOG_TAGS 结果集。
If no filterspec is found, filter defaults to '*:I'如果没有过滤说明,过滤规格默认为 *:I
If not specified with -v, format is set from ANDROID_PRINTF_LOG or defaults to "brief"如果没有 -v 指定格式,将是 ANDROID_PRINTF_LOG 或 brief 格式集。
1) 只输出指定 标签 和 类型 的日志&& 格式:&& adb logcat &日志标签&:&日志类型标识符& &日志标签&:&日志类型标识符& ... *:S&& 注:1. 可以写多个 &日志标签&:&日志类型标识符& 之间用空格分隔;&&   2. 最后必须是 *:S ,表示其它的都不要显示出来&& 例如:&& $ adb logcat dalvikvm:D Checkin:W *:S&& 注:adb logcat Checkin *:S =等同于=& adb logcat Checkin:V *:S&& 注:以上命令均没加 -v 来指出日志格式,即默认为: ANDROID_PRINTF_LOG 或 brief 格式集。
2) 输出指定 标签 和 类型 的带有格式的日志注:以下测试日志内容为:test log format,  即 eclipse 中的 logcat 图形界面里的 Text 中的内容!
1. brief&&&&& - 日志类型/日志标签(进程ID): 日志内容&& 例如:$ adb logcat -v brief Checkin *:S&&    I/Checkin(24713): test log format&&    2. process&&& - 日志类型(进程ID) 日志内容 (日志标签)&& 例如:$ adb logcat -v process Checkin *:S&&    I(24713) test log format& (Checkin)&&    3. tag&&&&&&& - 日志类型/日志标签: 日志内容&& 例如:$ adb logcat -v tag Checkin *:S&&&&&&& I/Checkin: test log format4. thread&&&& - 日志类型(进程ID:线程ID)&& 例如:$ adb logcat -v thread Checkin *:S&&&&&&& I(9) test log format5. raw&&&&&&& - 日志内容&& 例如:$ adb logcat -v raw Checkin *:S&&&&&&& test log format6. time&&&&&& - 日期 调用时间 日志类型/日志标签(进程ID): 日志内容&& 例如:$ adb logcat -v time Checkin *:S&& 05-27 11:25:33.854 I/Checkin(24713): test log format
7. threadtime - 日期 调用时间 进程ID 线程ID 日志类型 日志标签: 日志内容&& 例如:$ adb logcat -v time Checkin *:S&& 05-27 11:25:33.854
I Checkin: test log format&& 注:只有此种格式时 线程ID 为十进制数。8. long&&&&&& - [ 日期 调用时间 进程ID:线程ID 日志类型/日志标签 ] 转行显示 日志内容&& 例如:$ adb logcat -v long Checkin *:S&& [ 05-27 11:25:33.854 9 I/Checkin ]&& test log format
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具adb logcat命令行如何查看某个进程的log信息?
(已知进程的ID 和 有APK应用的源码)
[问题点数:20分,结帖人huabinsir]
adb logcat命令行如何查看某个进程的log信息?
(已知进程的ID 和 有APK应用的源码)
[问题点数:20分,结帖人huabinsir]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
2013年10月 移动开发大版内专家分月排行榜第三
匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。

我要回帖

更多关于 adb logcat 进程 的文章

 

随机推荐