Summary: This post shows several useful tips of viewing adb logcat output in shell command line.
When debugging, I usually find my screen be flooded by useless logs printed by someone else, and the logs that are useful to me are washed out at the same time. It really sucks. So I want to share some tips that I know for filtering the logs.
Please read Android official documentation Reading and Writing Logs first, which introduce the usage of the build-in filter of adb. It can filter logs by tags and by priority. If you prefer GUI, please refer to Using DDMS, which also provides the same filter.
An alternative way of filtering logcat output is using grep, which is the method that I want to share in the following paragragh.
1. White list
It's very easy to filter output by grep, and we can make use of the powerful regular expression matching function. An easy example is matching a string "MyApp" in any position of a log line:
adb logcat | grep MyApp
adb logcat | grep -i myapp #Ignore case
adb logcat | grep --color=auto -i myapp #Set color of matching string. See grep help for more details.
|