public class Logger extends Object
A Logger object is used to log messages for an Android application or any other java application.
This can be useful when developing an Android library, and we write unit tests (JUnit) and integration tests (Android Unit tests).
It is based on two types of log:
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.
To push files, open && browse in Terminal/CommandLine to ".../android_sdk/tools"
Syntax: " adb push <local_source> <emulator_destination> "
In our case, the file local.prop must contain at least:
log.tag.Logger = DEBUG
'Logger' tag is the default Logger class.
We can add more tags to their level if the application uses several different tags.
It uses the Jakarta Commons Logging (JCL). (http://commons.apache.org/logging/guide.html)
As far as possible, JCL tries to be as unobtrusive as possible. In most cases, including the (full) commons-logging.jar in the classpath should
result in JCL configuring itself in a reasonable manner.
There's a good chance that it'll guess (discover) your preferred logging system and you won't need to do any configuration of JCL at all!
Note, however, that if you have a particular preference then providing a simple commons-logging.properties file which specifies the concrete
logging library to be used is recommended, since (in this case) JCL will log only to that system and will report any configuration problems that
prevent that system being used.
Commons-Logging looks for a configuration file called commons-logging.properties in the CLASSPATH. This file must define, at the minimum,
the property org.apache.commons.logging.Log, and it should be equal to the fully qualified name of one of the implementations of the Log interface
listed above.
When no particular logging library is specified then JCL will silently ignore any logging library that it finds but cannot initialise and continue
to look for other alternatives. This is a deliberate design decision; no application should fail to run because a "guessed" logging library cannot
be used. To ensure an exception is reported when a particular logging library cannot be used, use one of the available JCL configuration mechanisms
to force that library to be selected (ie disable JCL's discovery process).
JCL is distributed with a very simple Log implementation named org.apache.commons.logging.impl.SimpleLog. This is intended to be a minimal
implementation and those requiring a fully functional open source logging system are directed to Log4J.
Simple implementation of Log that sends all enabled log messages, for all defined loggers, to System.err. The following system properties are
supported to configure the behavior of this logger:
In addition to looking for system properties with the names specified above, this implementation also checks for a class loader resource named
simplelog.properties, and includes any matching definitions from this resource (if it exists).
| Modifier | Constructor and Description |
|---|---|
protected |
Logger(String name,
Log log) |
| Modifier and Type | Method and Description |
|---|---|
void |
debug(String message,
Object... params) |
void |
debug(String message,
Throwable t,
Object... params) |
void |
error(String message,
Object... params) |
void |
error(String message,
Throwable t,
Object... params) |
void |
fatal(String message,
Object... params) |
void |
fatal(String message,
Throwable t,
Object... params) |
void |
info(String message,
Object... params) |
void |
info(String message,
Throwable t,
Object... params) |
boolean |
isDebugEnabled() |
boolean |
isErrorEnabled() |
boolean |
isFatalEnabled() |
boolean |
isInfoEnabled() |
boolean |
isTraceEnabled() |
boolean |
isWarnEnabled() |
void |
trace(Object message,
Object... params) |
void |
trace(String message,
Throwable t,
Object... params) |
void |
warn(String message,
Object... params) |
void |
warn(String message,
Throwable t,
Object... params) |
Copyright © 2014. All rights reserved.