adb logcat View logs


        The general usage of the command logcat to view and trace the system log buffer using the logcat command is :
[adb] logcat [<option>] ... [<filter-spec>] ...


You can use the logcat command to view the log output through a remote shell on the development machine:
$ adb logcat

If you are in a remote shell, you can use the command directly:
# logcat

Filtering log output
        Each log message has a tag and priority associated with it.
A token is a short string that identifies the source of the original message (eg "View" from the display system).
Priority is the following characters, in order from low to high:
V - detail (lowest priority)
D - debug
I - info
W - warning
E - error
F - critical error
S - undocumented (highest priority, nothing will is documented)
    A list of tags and priorities used in the system can be obtained by running logcat, observing the first two columns of the list, given in the format <priority>/<tag>.
    Here is a log output message with priority "I" and tag "ActivityManager":
I/ActivityManager( 585): Starting activity: Intent { action=android.intent.action...}

If you want to reduce the output content, you can add a filter expression to limit it. The filter can limit the system to output only the interesting tag-priority combination.
    The format of the filter expression is tag:priority ... , where tag is a tag, priority is the smallest priority, and all messages with a priority greater than or equal to the specified priority identified by this tag are written to the log. Multiple such filters can also be provided in one filter expression, separated by spaces.
    The example given below is to output only logs marked "ActivityManager" with priority greater than or equal to "Info" and logs marked "MyApp" and priority greater than or equal to "Debug":
adb logcat ActivityManager:I MyApp:D *:S

The *:S at the end of the above expression is used to set the log priority of all tags to S, which ensures that only logs marked "View" (Translator's Note: should be ActivityManager, the original text may be a typo) and "MyApp" log is output, using *:S is a recommended way to ensure that the output conforms to the specified filter settings, so that the filter becomes a "whitelist" of log output.
    The following expression is to display all logs with priority greater than or equal to "warning":
adb logcat *:W


=======================
Sometimes I feel that I can't see a lot of things in the console. You can execute this command under the command line to output the log to a file. ..
adb logcat *:V >b.txt

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327052421&siteId=291194637