Use Logcat Command
The general usage of the command logcat to View and track the system log buffers is:
[ADB] logcat [<option>] ... [<filter-spec>] ...
the filter and command options are described below, and the details can be found in Listing of Logcat Command Options .
You can use the logcat command to view the log output in the development machine by using the remote shell:
$ adb Logcat
If you are using the command directly in the remote shell:
# 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 ( For example , "View" originates from the display system ).
The priority is the following character, in order from low to High :
V - detail ( lowest priority )
D - Commissioning
I - information
W - warning
E - error
F - Critical Error
S - no record ( highest priority, nothing will be recorded )
by running Logcat , you can get a list of tags and priorities used in a system, the first two columns of the observation list, and the format given is <priority>/<tag> .
here is a log output message with a priority of " I ", Mark yes" Activitymanager ":
I/activitymanager (585): Starting activity:intent {action=android.intent.action ...}
If you want to reduce the content of the output, you can add the filter expression to limit, the filter can limit the system to output only the mark of interest - priority combination.
filter The format of the expression is tag:priority ... , where tag is the tag, priority is the smallest priority,
The example given below is that only the output is marked as " Activitymanager "and priority is greater than or equal to" Info "and marked as" MyApp "and priority is greater than or equal to" Debug "LOG:
adb logcatActivitymanager:IMyApp:D*:S
The above table Dashi the last *:s
s view "(Translator note: should be activitymanager 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 the "whitelist" of the log output.
The following expression shows that all priority is greater than or equal to " Warning "LOG:
adb logcat *: W
if Development run ( relative to the run operation shell ) android_log_tags
Android_log_tags = "activitymanager:i Myapp:d *:s "
It is important to note that if you are in a remote Shell or use adb shell logcat
Command Run logcat
, ANDROID_LOG_TAGS
not exported to the emulator or mobile device.
Control log Format
Log messages have a number of metadata fields beyond the mark and priority, which can be controlled by modifying the output format to control the output, and -v
the options listed below control the output field:
Brief - displays the PID of the priority/tag and the original process ( default format )
process- show PID only
Tag - Show priority / tag only
Thread - Show only processes: threads and priorities / tags
Raw - Displays the original log information with no other metadata fields
Time- display date, call duration, priority / tag,PID
Long - displays all metadata fields and separates message contents with blank lines
can use -v
Start logcat
to control the log format:
[ADB] logcat [-v <format>]
For example, using thread
output Format:
ADB logcat-v Thread
Note You -v
can only specify a format in the options.
viewing alternative Log buffers
the Android log system keeps multiple loop buffers for log messages, and not all messages are sent to the default buffers, and to view these additional buffers, you can use the -b
options The following are the buffers that can be specified:
Radio - View the messages contained in the wireless / phone-related buffers
Events- view event-related messages
Main - view Primary buffer ( default buffer )
-
Use of the B option:
[ADB] logcat [-b <buffer>]
For example, view the radio buffer:
ADB logcat-b Radio
ADB logcat viewing logs