public class Log
extends java.lang.Object
LogTarget
interface to use this feature.| Modifier and Type | Class and Description |
|---|---|
static class |
Log.SimpleMessage
A simple message class.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Log()
Creates a new Log instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTarget(LogTarget target)
Adds a log target to this facility.
|
static LogContext |
createContext(java.lang.Class context)
Creates a log context.
|
static LogContext |
createContext(java.lang.String context)
Creates a log context.
|
static void |
debug(java.lang.Object message)
A convenience method for logging a 'debug' message.
|
static void |
debug(java.lang.Object message,
java.lang.Exception e)
A convenience method for logging a 'debug' message.
|
protected static void |
defineLog(Log log)
Redefines or clears the currently used log instance.
|
protected void |
doLog(int level,
java.lang.Object message)
Logs a message to the main log stream.
|
protected void |
doLog(int level,
java.lang.Object message,
java.lang.Exception e)
Logs a message to the main log stream.
|
static void |
error(java.lang.Object message)
A convenience method for logging an 'error' message.
|
static void |
error(java.lang.Object message,
java.lang.Exception e)
A convenience method for logging an 'error' message.
|
int |
getDebuglevel()
Returns the currently defined debug level.
|
static Log |
getInstance()
Returns the singleton Log instance.
|
LogTarget[] |
getTargets()
Returns the registered logtargets.
|
static void |
info(java.lang.Object message)
A convenience method for logging an 'info' message.
|
static void |
info(java.lang.Object message,
java.lang.Exception e)
A convenience method for logging an 'info' message.
|
void |
init()
Initializes the logging system.
|
protected LogContext |
internalCreateContext(java.lang.String context)
Creates a log context.
|
static boolean |
isDebugEnabled()
Returns true, if the log level allows debug messages to be
printed.
|
static boolean |
isErrorEnabled()
Returns true, if the log level allows error messages to be
printed.
|
static boolean |
isInfoEnabled()
Returns true, if the log level allows informational
messages to be printed.
|
static boolean |
isWarningEnabled()
Returns true, if the log level allows warning messages to be
printed.
|
static void |
log(int level,
java.lang.Object message)
Logs a message to the main log stream.
|
static void |
log(int level,
java.lang.Object message,
java.lang.Exception e)
Logs a message to the main log stream.
|
void |
removeTarget(LogTarget target)
Removes a log target from this facility.
|
void |
replaceTargets(LogTarget target)
Replaces all log targets by the given target.
|
protected void |
setDebuglevel(int debuglevel)
Defines the debug level for the log system.
|
static void |
warn(java.lang.Object message)
A convenience method for logging a 'warning' message.
|
static void |
warn(java.lang.Object message,
java.lang.Exception e)
A convenience method for logging a 'warning' message.
|
protected Log()
public static Log getInstance()
protected static void defineLog(Log log)
log - the new log instance or null, to return to the default implementation.public int getDebuglevel()
protected void setDebuglevel(int debuglevel)
debuglevel - the new debug levelgetDebuglevel()public void addTarget(LogTarget target)
target - the target.public void removeTarget(LogTarget target)
target - the target to remove.public LogTarget[] getTargets()
public void replaceTargets(LogTarget target)
target - the new and only logtarget.public static void debug(java.lang.Object message)
message - the message.public static void debug(java.lang.Object message,
java.lang.Exception e)
message - the message.e - the exception.public static void info(java.lang.Object message)
message - the message.public static void info(java.lang.Object message,
java.lang.Exception e)
message - the message.e - the exception.public static void warn(java.lang.Object message)
message - the message.public static void warn(java.lang.Object message,
java.lang.Exception e)
message - the message.e - the exception.public static void error(java.lang.Object message)
message - the message.public static void error(java.lang.Object message,
java.lang.Exception e)
message - the message.e - the exception.protected void doLog(int level,
java.lang.Object message)
level - log level of the message.message - text to be logged.public static void log(int level,
java.lang.Object message)
level - log level of the message.message - text to be logged.public static void log(int level,
java.lang.Object message,
java.lang.Exception e)
The exception's stacktrace will be appended to the log-stream
level - log level of the message.message - text to be logged.e - the exception, which should be logged.protected void doLog(int level,
java.lang.Object message,
java.lang.Exception e)
The exception's stacktrace will be appended to the log-stream
level - log level of the message.message - text to be logged.e - the exception, which should be logged.public void init()
public static boolean isDebugEnabled()
public static boolean isInfoEnabled()
public static boolean isWarningEnabled()
public static boolean isErrorEnabled()
public static LogContext createContext(java.lang.Class context)
context - the class (null not permitted).public static LogContext createContext(java.lang.String context)
context - the label for the context.protected LogContext internalCreateContext(java.lang.String context)
context - the name of the logging context (a common prefix).