Log class abstract
API for sending log output.
Generally, you should use the Log.v, Log.d, Log.i, Log.w, and Log.e methods to write logs. You can then view the logs in logcat.
The order in terms of verbosity, from least to most is Log.error, Log.warn, Log.info, Log.debug, Log.verbose.
Tip: A good convention is to declare a TAG constant in your class:
private static const TAG = "MyClass";
and use that in subsequent calls to the log methods.
Tip: Don't forget that when you make a call like
Log.i(TAG, "My message");
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. 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.
Note: The return value from the logging functions in this class may vary between Android releases due to changes in the logging implementation. For the methods that return an integer, a positive value may be considered as a successful invocation.
Constructors
- Log()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
d(
String tag, String msg) → int - Send a debug log message.
-
e(
String tag, String msg) → int - Send an error log message.
-
i(
String tag, String msg) → int - Send an info log message.
-
isLoggable(
String tag, int level) → bool - Checks to see whether or not a log for the specified tag is loggable at the specified level. The default level of any tag is set to INFO. This means that any level above and including INFO will be logged. Before you make any calls to a logging method you should check to see if your tag should be logged. You can change the default level by setting a system property: 'setprop log.tag.<YOUR_LOG_TAG> <LEVEL>' Where level is either verbose, debug, info, warn, error, or assert_. You can also create a local.prop file that with the following in it: 'log.tag.<YOUR_LOG_TAG>=<LEVEL>' and place that in /data/local.prop.
-
println(
int priority, String tag, String msg) → int - Low-level logging call.
-
v(
String tag, String msg) → int - Send an verbose log message.
-
w(
String tag, String msg) → int - Send an warn log message.
-
wtf(
String tag, String msg) → int - What a Terrible Failure: Report a condition that should never happen. The error will always be logged at level ASSERT with the call stack. Depending on system configuration, a report may be added to the DropBoxManager and/or the process may be terminated immediately with an error dialog.
Constants
- assert_ → const int
- Priority constant for the println method.
- debug → const int
- Priority constant for the println method; use Log.d.
- error → const int
- Priority constant for the println method; use Log.e.
- info → const int
- Priority constant for the println method; use Log.i.
- verbose → const int
- Priority constant for the println method; use Log.v.
- warn → const int
- Priority constant for the println method; use Log.w.