* Note: You can use ADB logcat > Path/filename to save,
All log information from the time of execution of this command to a file, CTRL + C to end the log output;
After no > path/filename, then output in stdout (terminal window)!
Example: $ adb logcat-v long Checkin *:s > ~/Desktop/log.txt
First, in Java and C language output log:
1 Java code output log in the program, using the following 5 methods of the Android.util.Log class:
LOG.V (), LOG.D (), LOG.I (), LOG.W (), LOG.E ().
correspond to Verbose, Debug, INFO, Warn, Error first letter.
For example: LOG.I ("Class:: Function Name", "Date _ time _ source file Name _ line number _ Log information content");
2 C code in the program output log, using the log API function:
__android_log_write (log type macro, log label string, log token content string);
Required: 1. Add Local_ldlibs in Android.mk: =-l$ (sysroot)/usr/lib-llog
2. Add #include <android/log.h> in *.c
3. The log type macros are:
Copy Code code as follows:
Android log priority values, in the ascending priority order.
typedef enum ANDROID_LOGPRIORITY {
Android_log_unknown = 0,
Only for Setminpriority ()
Android_log_default,
Android_log_verbose,
Android_log_debug,
Android_log_info,
Android_log_warn,
Android_log_error,
Android_log_fatal,
Only for setminpriority (); Must be last
Android_log_silent,
} android_logpriority;
Second, Logcat use method:
usage:logcat [Options] [Filterspecs]
Usage: logcat [options] [Filter description]
Options include:
Options include:
-S Set default filter to silent.
Like specifying Filterspec ' *:s '
Set the default filter to silent.
Like the specified filter description for *:s, see the following Filter description section detailing
-F <filename> Log to file.
Default to stdout
Output log to file.
Default is stdout
-R [<kbytes>] Rotate log every kbytes.
(if unspecified).
Requires-f
Sets the Kbytes of the ring log buffer.
The default value is 16.
Needs to be used with the-f option
-N <count> Sets max number of rotated logs to <count>, default 4
Sets the maximum number of ring log buffers, the default value is 4, and is required with the-r option
-V <format> Sets The log print format, where <format> is one of:
The format of the log is formatted with the following main 7 types: (cannot be used in combination)
Brief
Process
Tag
Thread
Raw
Time
ThreadTime
Long
-C-Clear (flush) the entire log and exit
Clear all log and exit
-D Dump the log and then exit (Don ' t block)
Get all log and exit without blocking
-T <count> print only the most recent <count> lines (implies-d)
Print only the most recent number of rows indicated by parameter count (necessarily contains-D)
G Get the size of the log's ring buffer and exit
Gets the size of the ring buffer and exits
-B <buffer> Request alternate ring buffer, ' main ', ' System ', ' radio ' or ' events '.
Multiple-b parameters are allowed and the results are.
The default Is-b main-b system.
A ring buffer, such as main,system,radio,events, that is requested for replacement.
Multiple-B parameters are allowed and the result is interleaved.
The-B main-b system is default.
-B Output the log in binary
Output log to binary file.
Filterspecs are a series of <tag>[:p Riority]
Filtration description is a series of <tag>[:p Riority]
Where <tag> is a log component tag (or * to all) and priority is:
tag is the content of the tag in the Logcat graphical interface in Eclipse (or all of the * means), followed by a colon (:) followed by a priority:
Log type identifiers (precedence is arranged from lowest to highest):
1. V-verbose Detailed <-Minimum priority
2. D-debug Debugging
3. I-info News
4. W-warn Warning
5. E-error Error
6. F-fatal Lethal
7. S-silent Silent <-Highest priority
' * ' means ' *:d ' and <tag> by itself means <tag>:v
* means *:d and single tag means tag:v
If not specified on the commandline, Filterspec are set from Android_log_tags.
If not specified on the command line, the filter specification is the android_log_tags result set.
If no filterspec is found, filter defaults to ' *:i '
If no filtering instructions, the filter specification defaults to *:I
If not specified with-v, the format is set from Android_printf_log or defaults to "brief"
If you do not have the-V specified format, it will be a android_printf_log or brief format set.
1) output only the specified label and type of log
Format:
ADB logcat < log label >:< log type identifier > < log label >:< log type identifier > ... *:s
Note: 1. Can write multiple < log tags >:< log type identifiers > separated by spaces;
2. Finally, it must be *:s to show that nothing else should be shown.
For example:
$ adb logcat dalvikvm:d Checkin:w *:s
Note: adb logcat Checkin *:s = equivalent to => adb logcat checkin:v *:s
Note: The above command does not add-V to indicate the log format, that is, the default is: Android_printf_log or brief format set.
2 output a formatted log of the specified label and type
Note: The following test log content is: Test log format,
That is, the contents of Text in the Logcat graphical interface in Eclipse!
1. Brief-Log Type/log label (process ID): Log contents
For example: $ adb logcat-v brief Checkin *:s
I/checkin (24713): Test log format
2. Process-log type (process ID) log content (journal label)
For example: $ adb logcat-v process Checkin *:s
I (24713) test log format (Checkin)
3. Tag-journal type/log label: Log content
For example: $ adb logcat-v tag Checkin *:s
I/checkin:test log Format
4. Thread-log type (process ID: Thread ID)
For example: $ adb logcat-v thread Checkin *:s
I (24713:0x6089) test log format
5. Raw-Log content
For example: $ adb logcat-v Raw Checkin *:s
Test log format
6. Time-Date Call log type/log label (process ID): Log contents
For example: $ adb logcat-v time Checkin *:s
05-27 11:25:33.854 I/checkin (24713): Test log format
7. ThreadTime-Date call time process ID thread ID log type Journal label: Log Content
For example: $ adb logcat-v times Checkin *:s
0 5-27 11:25:33.854 24713 24713 I checkin:test log format
NOTE: The thread ID is a decimal number only in this format.
8. long -[Date call time process ID: Thread ID log type/log Label] Career change display log content
For example: $ adb l Ogcat-v long Checkin *:s
[05-27 11:25:33.854 24713:0x6089 I/checkin]
test log format