java.lang.Object | ||
android.util.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:
private static final String TAG = "MyActivity";and use that in subsequent calls to the log methods.
Tip: Don't forget that when you make a call like
Log.v(TAG, "index=" + i);that when you're building the string to pass into Log.d, Java uses 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 that if your log message is filtered out, you might be doing significant work and incurring significant overhead.
Value | ||||
---|---|---|---|---|
int | ASSERT | Priority constant for the println method. | 7 | 0x00000007 |
int | DEBUG | Priority constant for the println method; use Log.d. | 3 | 0x00000003 |
int | ERROR | Priority constant for the println method; use Log.e. | 6 | 0x00000006 |
int | INFO | Priority constant for the println method; use Log.i. | 4 | 0x00000004 |
int | VERBOSE | Priority constant for the println method; use Log.v. | 2 | 0x00000002 |
int | WARN | Priority constant for the println method; use Log.w. | 5 | 0x00000005 |
static | int | d(String tag, String msg, Throwable tr) | ||||
Send a DEBUG log message and log the exception. | ||||||
static | int | d(String tag, String msg) | ||||
Send a DEBUG log message. | ||||||
static | int | e(String tag, String msg) | ||||
Send an ERROR log message. | ||||||
static | int | e(String tag, String msg, Throwable tr) | ||||
Send a ERROR log message and log the exception. | ||||||
static | String | getStackTraceString(Throwable tr) | ||||
Handy function to get a loggable stack trace from a Throwable | ||||||
static | int | i(String tag, String msg, Throwable tr) | ||||
Send a INFO log message and log the exception. | ||||||
static | int | i(String tag, String msg) | ||||
Send an INFO log message. | ||||||
static | boolean | isLoggable(String tag, int level) | ||||
Checks to see whether or not a log for the specified tag is loggable at the specified level. | ||||||
static | int | println(int priority, String tag, String msg) | ||||
Low-level logging call. | ||||||
static | int | v(String tag, String msg, Throwable tr) | ||||
Send a VERBOSE log message and log the exception. | ||||||
static | int | v(String tag, String msg) | ||||
Send a VERBOSE log message. | ||||||
static | int | w(String tag, String msg) | ||||
Send a WARN log message. | ||||||
static | int | w(String tag, Throwable tr) | ||||
static | int | w(String tag, String msg, Throwable tr) | ||||
Send a WARN log message and log the exception. |
tag | Used to identify the source of a log message. It usually identfies the class or activity where the log call occurs. |
---|---|
msg | The message you would like logged. |
tr | An exception to log |
tag | Used to identify the source of a log message. It usually identfies the class or activity where the log call occurs. |
---|---|
msg | The message you would like logged. |
tag | Used to identify the source of a log message. It usually identfies the class or activity where the log call occurs. |
---|---|
msg | The message you would like logged. |
tag | Used to identify the source of a log message. It usually identfies the class or activity where the log call occurs. |
---|---|
msg | The message you would like logged. |
tr | An exception to log |
tr | An exception to log |
---|
tag | Used to identify the source of a log message. It usually identfies the class or activity where the log call occurs. |
---|---|
msg | The message you would like logged. |
tr | An exception to log |
tag | Used to identify the source of a log message. It usually identfies the class or activity where the log call occurs. |
---|---|
msg | The message you would like logged. |
tag | The tag to check. |
---|---|
level | The level to check. |
IllegalArgumentException | is thrown if the tag.length() > 23. |
---|
priority | The priority/type of this log message |
---|---|
tag | Used to identify the source of a log message. It usually identfies the class or activity where the log call occurs. |
msg | The message you would like logged. |
tag | Used to identify the source of a log message. It usually identfies the class or activity where the log call occurs. |
---|---|
msg | The message you would like logged. |
tr | An exception to log |
tag | Used to identify the source of a log message. It usually identfies the class or activity where the log call occurs. |
---|---|
msg | The message you would like logged. |
tag | Used to identify the source of a log message. It usually identfies the class or activity where the log call occurs. |
---|---|
msg | The message you would like logged. |
Copyright 2007 Google Inc. | Build 0.9_r1-98467 - 14 Aug 2008 18:48 |