An explanation of the log mechanism in Android

Source: Internet
Author: User
Tags print format

There are several types of log output in Android:

LOG.V (string tag, string msg); VERBOSE
LOG.D (string tag, string msg); DEBUG
LOG.I (string tag, string msg); INFO
LOG.W (string tag, string msg); WARN
LOG.E (string tag, string msg); ERROR

The above log level in turn, VERBOSE debug information should only exist in the development, info,warn,error these three kinds of log will appear in the release version.

For Java classes, you can declare a string constant Tag,logcat can distinguish between different logs based on him, for example in a class of Windowsmanagerservice.java, as defined below:
Static final Sting TAG = "WindowManager"
Where you need to hit log.
LOG.V (TAG, "figuring out where to add App window" + client.asbinder () + "(token=" + token + ")");

Logcat use the following method:

logcat [Options] [Filterspecs]
Option "-S" is used to set the filter, the format is such <tag>[:p riority]
Where <tag> means log component, tag (or use * for all), the priority is as follows:
V Verbose
D Debug
I Info
W Warn
E Error
F Fatal
S Silent

Cases:
Logcat-s *:s don't hit any log
Logcat-s windowmnager:v <--Printing Verbose information in Windowmanagerservice
If you view the Android log output in Eclipse, which is LogCat information, you can choose Windows > Show View > Other ... > Android > LogCat.

Report
Logcat parameter Description:
usage:logcat [Options] [Filterspecs]
Options include:
-S Set default filter to silent.
Like specifying Filterspec ' *:s '
-F <filename> Log to file. Default to stdout
-R [<kbytes>] Rotate log every kbytes. (if unspecified). Requires-f
-N <count> sets max number of rotated logs to <count>, default 4
-V <format> sets the log print format, where <format> is one of:

Brief process Tag thread raw time long

-C Clear (flush) the entire log and exit
-D Dump the log and then exit (Don ' t block)
-G get the size of the log ' s ring buffer and exit
-B <buffer> Request alternate ring buffer, defaults to ' main '
Filterspecs is a series of
<tag>[:p Riority]

Where <tag> is a log component tag (or * for all) and the IS:
V Verbose
D Debug
I Info
W Warn
E Error
F Fatal
S Silent (supress all output)

' * ' means ' *:d ' and <tag> by itself means <tag>:v

If not specified on the commandline, Filterspec are set from Android_log_tag
If no filterspec is found, filter defaults to ' *:i '

If not specified WITH-V, format was set from Android_printf_log
or defaults to "brief"

Related Article

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.