The Log class describes:
API for sending log output. Generally, use the log.v () log.d () log.i () LOG.W () and LOG.E () methods.
The order in terms of verbosity, from least to most are ERROR, WARN, INFO, DEBUG, VERBOSE.
Verbose should never be compiled to an application except during development. Debug logs is compiled in and stripped at runtime.
Error, warning and info logs is always kept.
TIP:
A good convention is to declare a TAG
constant with your class: and use that in private static final String TAG = "MyActivity";
subsequent calls to the log methods.
TIP:
Don ' t forget that's when do a call like that if you Log.v(TAG, "index=" + i);
' re building the string to pass into LOG.D, the compiler US Es a StringBuilder and at least three allocations occur:the StringBuilder itself, the buffer, and the String object.
Realistically, there is also another buffer allocation and copy, and even more pressure on the GC. That means this if your log message is filtered out, you might be doing significant work and incurring significant overhea D.
The log class is android.util
in the package, and there are some static methods.
The default output is to use the log class.
Several important methods of the Log Class 1. LOG.V ()
V, verbose, Chinese: verbose, output the most common information.
Two overloads:
publicstaticintvpublicstaticintv(String tag, String msg, Throwable tr)
tag is the tag, generally called the name of the class, MSG is the output information, the other output method is similar.
2.LOG.D ()
d, debug, output debug information.
3.LOG.I ()
I, i.e. information, outputs general information.
4.LOG.W ()
W, i.e. warning, warning message.
5.LOG.E ()
E, which is error, outputs a false message.
Basic usage of Android log class