There are several way to see the output file. Here comes two ways to see it in the terminal:
1. Directly from the terminal
adb -d logcat2. From the device terminal
2.1 Access to the Android's shell
adb -d shell2.2 Invoke logcat
The command logcat has several options and filters. The structure of it is:
logcat [options] [filterspecs]
You can see all them invoking help:
adb -d logcat --helpor
In the Android official devguide you have the complete options also:
For me, the most interesting options are:
- -d: This option make the shell dump the log and then exit. Normally the listener of log is always running and it will stop until the device is disconnected or turned off. It is very useful to see just commands from this moment and exit.
- -s: Set default filter to silent. It works exactly as the filter "*:S" (Explained below). This is used to ensure that only messages with "View" tag and the specified in the command tag will be displayed.
- -f <filePath+fileName>: Set the output as a file in a specific path. Notices that the root path of android is read only. The best way is storing the file in /sdcard. For example, to store it to "output.txt" file in /sdcard, the option is
adb -f /sdcard/output.txtFilters
- -b <buffer>: Switch between different buffers. There are three buffers: main, event and radio. The default one is main. The event buffer is specially useful to see all the lifecycle of the activities happening in the phone (Creating, destroying, pausing, resuming, etc)
The filters has the follow structure:
<tag>[:priority]The priority corresponds to the priority that a log message can have. That are:
- Verbose: V
- Debug: D
- Info: I
- Warning: W
- Error: E
- Fatal: F
- Silent: S
If a priority is set, then all the messages with that priority or more restrictive priority will be shown.
logcat -d myApp:D *:Swill show all the messages that has tag "myApp" and has priority D, I, W, E, F and S.
The tag :*S (or the option -s) is very important. It will ensure that only the messages which has specific tag and which has the specific level or more restrictives one will be displayed.
The filters can be put together by writing a priority behind another. For example:
logcat -d myApp:D myApp2:W *:Swill display all the messages that has tag "myApp" which has the priority D or more restrictives one AND all the messages that has tag "myApp2" which has the priority W or more restrictives one.
Things to take account
- The tag can be work without any kind of priority. The default on is V (verbose)
- By default, logcat doesn't display the time. If you need it, then the option "-v time" can be used.
- The tags are case sensitive. That means they are sensitive to mayus-minus. For example, the tag "youtube" is different from the tag "YouTube"
- Unlike in the eclipse, here is not option to filter the process by pid. One way to do it manually is using grep. Be careful because the pid in the Android has 5 ciphers. If the pid you want to filter has just two ciphers (like 77), you should put some white space before. For example, to filter all the process which has the pid 77, the command could be used is (with three white space):
adb logcat -d | grep "( 77)"
Android official devguide: http://developer.android.com/guide/developing/tools/adb.html#logcat