Log 类介绍:
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 is ERROR, WARN, INFO, DEBUG, VERBOSE.
Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime.
Error, warning and info logs are always kept.
Tip:
A good convention is to declare a TAG constant in your class:
and use that in subsequent calls to the log methods.
- private static final String TAG = "MyActivity";
Tip:
Don't forget that when you make a call like
that when you're building the string to pass into Log.d, the compiler uses a StringBuilder and at least three allocations occur: the StringBuilder itself, the buffer, and the String object.
- Log.v(TAG, "index=" + i);
Realistically, there is also another buffer allocation and copy, and even more pressure on the gc. That means that if your log message is filtered out, you might be doing significant work and incurring significant overhead.
来源: http://www.bubuko.com/infodetail-2445695.html