Android logcat Command Detailed

Source: Internet
Author: User

First, logcat command introduction 1.android log system

2.logcat Introduction

Logcat is a command-line tool in Android that can be used to get log information for a program

The log class is a logging class that allows you to print out messages using Logcat in your code

    • Common logging methods include the following:

Method

Describe

V (string,string) (Vervbose) Show All information
D (string,string) (Debug) Display Debug Information
I (string,string) (information) Show General Information
W (string,string) (waning) displaying warning messages
E (string,string) (Error) Display error message

For example:

// get log during the development process LOG.I ("MyActivity", "Myclass.getview ()-Get Item number" +position); // ADB acquires logadb logcat

The log format for the ADB logcat output is as follows:

Long for: servicerecord{2b24178c u0 Com.google.android.gms/.checkin. Checkinservice}

3.LOGCAT command format

Syntax format:

[ADB] logcat [<option>] ... [<filter–spec>] ...

PC-Side use:

ADB logcat

Use in Shell mode:

Logcat

Ii. Logcat Buffer 1. Introduction to Buffers

Android log output is huge, especially the log of the communication system, so Android output log to a different buffer, currently defines four log buffers:

1) Radio: Log of the output communication system

2) System: Log of output system components

3) Event: Outputs the log of the event module

4) Main: All Java layer log, the relic does not belong to the above 3 layer log

Buffers are primarily used by system components, and general applications do not need to be concerned with the application's log output to the main buffer

The default log output (without a buffer specified) is the log of the output system and main buffer

2. Buffer model

3. Get buffer command

Parameters

Describe

-b<buffer> Load a log buffer that can be used to provide a view, the default value is main
4. Example
ADB logcat–b radioadb logcat–b systemadb logcat–b eventsadb logcat–b Main
Iii. logcat Command parameters 1. Parameter description

Parameters

Describe

b <buffer> Load a log buffer that can be used for viewing, such as event and radio. The default value is main
-C Clears all the logs in the buffer and exits (you can use the-G to view the buffers when you are done clearing)
-D Dump the log of the buffer to the screen and exit
-F <filename> Output log to the specified file < filename; default to standard output (stdout)
-G Print the size of the log buffer and exit
-N <count> Set the maximum number of logs <count> The default value is 4 and needs to be used with the-r option
-R <kbytes> Output log without <kbytes>, default value is 16, need to use with-f option
-S Set Filter
-V <format> Sets the output format of the log message. The default is a short format. List of supported formats

General output log for a long time is recommended-f,-n,-r three parameters, so that when a file log output is full, you can immediately in the other output

2. Example
// Print the log of the buffer to the screen and exit adblogcat-// Clear buffer log (TestCase can be cleared first before running)adb logcat-C  // Print buffer size and exit adb logcat-g// output logadb logcat-f/data/local/tmp/ Log.txt-n 10-r 1
Iv. logcat formatted output 1. Parameter description

The log message contains a metadata field, in addition to the label and priority, you can modify the output to display a specific metadata field in the format of the message. To do this, you use the-V option to specify a supported output format. For the supported formats:

Format

Description

Brief Displays the priority/token and PID messages emitted by the process (default format)
Process Show PID only
Tag Show priority/Tag only
Raw Show original log messages, no additional metadata fields
Time Call the PID that displays the date, time, priority/label, and procedure to emit a message
ThreadTime Call display date, time, priority, tag ruins PID message sent by the TID thread
Long Show all metadata fields with blank lines and separate messages

When Logcat starts, specify that you want the output format-V option:

[ADB] logcat [-v <format>]

ADB logcat–v Thread

Only one output format can be specified-V

2. Example

V. LOGCAT Priority 1. Precedence syntax

Priority is identified with a character, and the priority level is low to high

V–verbose (Lowest priority)

D–debug

I–info

W–warning

E–error

F–fatal

S–silent

In order to reduce the output of the log, you can create a filter

Filter Syntax: tag:priority

// filter tag for Activitymanager output level greater than I log with tag for MyApp output level greater than D log adb logcat activitymanager:i   *:s

ADB logcat *:w

Set the filter level to more than W

If you use more than you can set the environment variable:

Export android_log_tags= "activitymanager:i Myapp:d*:s "

Android logcat Command Detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.