Trying to output my LogCat to a file

雨燕双飞 提交于 2019-12-04 19:49:00

问题


I've been told it's a command line option. But Eclipse's Run!Run Configurations...!Target!Additional Emulator Command Line Options field is already occupied with

-sdcard "C:\android-sdk-windows\tools\sd9m.img"

If I wanted to write something like

adb logcat -s MessageBox > "C:\Users\me\Documents\LogCatOutput.txt"

then where do I write it, and how (i.e., is the syntax even correct)? I need to output only a filtered tag, not verbose. ("MessageBox" is my TAG. Again I don't know if any of this punctuation is right, or even where the command goes.)

Thanks for any help.


回答1:


There should be an adb.exe file in C:\android-sdk-windows\tools. You can invoke this manually from a DOS command prompt:

cd C:\android-sdk-windows\tools
adb logcat -s MessageBox > "C:\Users\me\Documents\LogCatOutput.txt"

There's no need to bother with Eclipse in this case.




回答2:


Alternatively, if you only want to dump whatever's already in the logcat buffers and exit immediately (useful for scripts), you can specify the -d option:

$ adb logcat -d -s MessageBox  > dump_file.txt

Make sure that '-d' is after 'logcat'.




回答3:


Another useful addition to the above answers is filtering. The application I am working on generates a massive amount of logging, so it is useful to log with filters.

adb -s MyDevice logcat | find /V ": T#" > d:\temp\logcat.txt

or for OSX/Linux

adb -s MyDevice logcat | grep -v ": T#" > ~/logcat.txt

This will write all logcat activity apart from any line that contains ": T#"

find or grep can also be used to filter based on positive results. I then use the likes of BareTail display the growing log file.



来源:https://stackoverflow.com/questions/3153910/trying-to-output-my-logcat-to-a-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!