|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.adventnet.afp.log.AbstractLogger | +--com.adventnet.afp.log.DefaultLogger
This class is the default implementation of a Logger. In a situation
where some file operations are not permitted or error occurs during log
module initialization,it is highly essential that all log messages are
redirected to the console. This can be achieved by redirecting all the
log messages to System.out and System.err. For doing this, DefaultLogger is used.
The class DefaultLogger is the default implementation of a Logger. The Log messages will be displayed on the console based on the LogLevel of the message.
The LoggerProperties such as InstanceName, DisplayName, ClassName,
LogLevel etc., are received from the LogWriter. The output from the
Logger can be redirected to some other file, by changing the LogWriter
at runtime.
The various methods used in Default Logger are almost same as those
used in the Logger. The err method can be used for logging the error messages
with the exception trace. The message will be formatted by the formatMessage
method. The default formatting has the time stamp in the format "hh:mm:ss:SSS
DisplayName".
Similarly, the out method can be used for Logging general output messages and debugging messages. The message will be formatted using the method formatMessage. The default formatting has the time stamp in the format "hh:mm:ss:SSS DisplayName".
In both the cases stated above, the message will be logged only if the level of the message is less than or equal to the Logger's logging level.
@see Logger
Fields inherited from class com.adventnet.afp.log.AbstractLogger |
listeners, loggingLevel |
Constructor Summary | |
DefaultLogger()
Creates a new DefaultLogger instance with default Logger properties. |
Method Summary | |
void |
err(java.lang.String message,
int level)
The err method can be used for logging the error messages. |
void |
err(java.lang.String message,
java.lang.Throwable exception,
int level)
The err method can be used for logging the error messages
with the exception trace. |
java.lang.String |
formatMessage(java.lang.String message,
int level)
formatMessage method formats the message to a custom format. |
void |
init(LoggerProperties loggerProps,
LogWriter logWriter)
The init method is used to intialize the DefaultLogger. |
void |
out(java.lang.String message,
int level)
The out method can be used for Logging general output
messages and debugging messages. |
Methods inherited from class com.adventnet.afp.log.AbstractLogger |
addPropertyChangeListener, getInstanceName, getLogLevel, removePropertyChangeListener, setLogLevel |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DefaultLogger()
DefaultLogger
instance with default Logger properties.Method Detail |
public void init(LoggerProperties loggerProps, LogWriter logWriter) throws LogException
init
method is used to intialize the DefaultLogger. A logger will
become active and would start handling inputs only after it is initialized. The logger
properties and Log Writer are passed to this method.init
in class AbstractLogger
loggerProps
- specifies the properties of the LoggerlogWriter
- instance to which the Logger has to be associated.public void out(java.lang.String message, int level)
out
method can be used for Logging general output
messages and debugging messages. The message will be formatted using
the formatMessage(java.lang.String, int)
. The defualt formatting
has the time stamp in the format "hh:mm:ss:SSS DisplayName"
The message will be logged only if the
level of the message is less than or equal to that of the Logger's
logging level.message
- String
valuelevel
- an int
valuepublic void err(java.lang.String message, int level)
err
method can be used for logging the error messages. The message will be
formatted using the formatMessage(java.lang.String, int)
. The defualt formatting has the
time stamp in the format "hh:mm:ss:SSS DisplayName"
The message will be logged only if the
level of the message is less than or equal to that of the Logger's
logging level.message
- String
value describing the exceptionlevel
- an int
logging valuepublic void err(java.lang.String message, java.lang.Throwable exception, int level)
err
method can be used for logging the error messages
with the exception trace. The message will be formatted using
the formatMessage(java.lang.String, int)
. The defualt formatting
has the time stamp in the format "hh:mm:ss:SSS DisplayName"
The message will be logged only if the
level of the message is less than or equal to that of the Logger's
logging level.message
- String
value describing the exceptionexception
- a Throwable
exceptionlevel
- an int
logging valuepublic java.lang.String formatMessage(java.lang.String message, int level)
formatMessage
method formats the message to a custom format.
In the defualt formatting, the message is prepended with the time stamp in the
format "hh:mm:ss:SSS DisplayName". This method can be overridden
to get the message in the user-defined format.message
- a String
valuelevel
- an int
valueString
value
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |