|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.samskivert.util.Logger
public abstract class Logger
Provides logging services to this library and others which depend on this library in such a way that they can be used in a larger project and easily be made to log to the logging framework in use by that project.
The default implementation uses log4j if it is available and falls back to the Java logging services if not. A specific (or custom) logging implementation can be configured like so:
-Dcom.samskivert.util.Logger=com.samskivert.util.Log4Logger
One additional enhancement is the use of varargs log methods to allow for some handy automatic formatting. The methods take a log message and list of zero or more additional parameters. Those parameters should be key/value pairs which will be logged like so:
message [key=value, key=value, key=value]
The final parameter can optionally be a Throwable, which will be supplied to the underlying log system as an exception to accompany the log message.
| Nested Class Summary | |
|---|---|
static interface |
Logger.Factory
Used to create logger instances. |
| Field Summary | |
|---|---|
protected static Logger.Factory |
_factory
|
| Constructor Summary | |
|---|---|
Logger()
|
|
| Method Summary | |
|---|---|
protected static Logger.Factory |
createConfiguredFactory()
A helper function for initLogger(). |
abstract void |
debug(Object message,
Object... args)
Logs a debug message. |
abstract void |
error(Object message,
Object... args)
Logs an error message. |
protected String |
format(Object message,
Object[] args)
Format messages and arguments. |
protected Throwable |
getException(Object message,
Object[] args)
Extracts the exception from the message and arguments (if there is one). |
static Logger |
getLogger(Class<?> clazz)
Obtains a logger with a name equal to the supplied class's name. |
static Logger |
getLogger(String name)
Obtains a logger with the specified name. |
abstract void |
info(Object message,
Object... args)
Logs an info message. |
protected static void |
initLogger()
Called at static initialization time. |
static void |
setFactory(Logger.Factory factory)
Configures the logging factory be used by the logging system. |
abstract void |
warning(Object message,
Object... args)
Logs a warning message. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static Logger.Factory _factory
| Constructor Detail |
|---|
public Logger()
| Method Detail |
|---|
public static Logger getLogger(String name)
public static Logger getLogger(Class<?> clazz)
public static void setFactory(Logger.Factory factory)
com.samskivert.util.Logger system property instead,
but in some situations, like in an applet, you cannot pass system properties and we can't
read them anyway because we're running in a security sandbox.
public abstract void debug(Object message,
Object... args)
message - the message to be logged.args - a list of key/value pairs and an optional final Throwable.
public abstract void info(Object message,
Object... args)
message - the message to be logged.args - a list of key/value pairs and an optional final Throwable.
public abstract void warning(Object message,
Object... args)
message - the message to be logged.args - a list of key/value pairs and an optional final Throwable.
public abstract void error(Object message,
Object... args)
message - the message to be logged.args - a list of key/value pairs and an optional final Throwable.
protected String format(Object message,
Object[] args)
protected Throwable getException(Object message,
Object[] args)
protected static void initLogger()
protected static Logger.Factory createConfiguredFactory()
initLogger().
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||