com.resilientedge.util.logger
Class Logger

java.lang.Object
  |
  +--com.resilientedge.util.logger.Logger
Direct Known Subclasses:
SimpleLogger

public abstract class Logger
extends java.lang.Object

This class defines the basic behavior for a Logger. A Logger object is used to generate log messages. Loggers create LogRecords and hand them to Handlers for proccessing and exporting. A Logger can have one or more Handlers, and will pass the LogRecord to all of its known handlers (assuming the Logger's filter allows it). A Logger can use a Filter to filter out messages that should not be logged. If no filter is used, then log messages of any level can be logged. If logging by key, the Logger can perform a lookup of the key from a message store (such as a resource bundle). In this way, the messages text can be maintained externally, but refrenced internally by key. By Default, loggers process log messages asynchronously. Use setAsync( false ) to configure the logger to process log records synchronously.

About Usage

In general, the logger can be used with the following syntax:   Logger.getInstance().log( "foo" );

About Logger Properties

If a logger obtains its configuration from the properties system, two keys are required.

Author:
odh

Field Summary
static java.lang.String LOG_FILTER
          Description of the Field
static java.lang.String LOG_HANDLERS
          Description of the Field
static int MAX_POOL_SIZE
          Description of the Field
static int MIN_POOL_SIZE
          Description of the Field
 
Constructor Summary
Logger()
           
 
Method Summary
 void addHandler(Handler handler)
          Add a handler to the Logger's list of Handlers.
 Filter getFilter()
          Return the Logger's filter.
 java.util.Iterator getHandlers()
          Returns an Iterator for the handlerList.
static Logger getInstance()
          This method will attempt to locate a more highly configured logger from the Log Factory.
protected  WorkerPool getWorkerPool()
          This method returns the Logger's workerPool.
protected  void init()
          This method performs any Logger initialization.
 boolean isAsync()
          The method returns true if the logger can process log records asynchronously.
 boolean isEnabled()
          State of the Logger
abstract  void log(java.lang.String rawMessage)
          This method is for free form trace-logging where the level is assumed to be Trace and the message text does not represent a lookup key.
abstract  void log(java.lang.String rawMessage, int level)
          This method is for free form logging where a level and the logging message are supplied.
abstract  void log(java.lang.String key, java.lang.Object[] insertValues)
          Deprecated.  
abstract  void log(java.lang.String key, java.lang.Object[] insertValues, int level)
          Deprecated.  
abstract  void log(java.lang.String key, java.lang.Object[] insertValues, java.lang.Throwable exception)
          Deprecated.  
abstract  void log(java.lang.String key, java.lang.Object[] insertValues, java.lang.Throwable exception, int level)
          Deprecated.  
abstract  void log(java.lang.String topic, java.lang.String rawMessage, int level)
          This method is for free form logging where a level and topic are provided in addition to the logging message.
abstract  void log(java.lang.String topic, java.lang.String key, java.lang.Object[] insertValues, int level)
          This method is used to log by lookup key.
abstract  void log(java.lang.String topic, java.lang.String key, java.lang.Object[] insertValues, java.lang.Throwable exception, int level)
          Deprecated.  
abstract  void log(java.lang.String topic, java.lang.String rawMessage, java.lang.Throwable exception, int level)
          Log a message by lookup key.
abstract  void log(java.lang.String rawMessage, java.lang.Throwable exception)
          Log a message and exception.
abstract  void log(java.lang.String rawMessage, java.lang.Throwable exception, int level)
          Log a message, exception and level.
abstract  void log(java.lang.Throwable exception, int level)
          Log an exception with a level but without a message.
 boolean removeHandler(Handler handler)
          Remove a handler from the Logger's list of handlers.
 void setAsync(boolean async)
          Sets the Logger's ability to process logRecords asynchronously.
static void setDefault(Logger logger)
          Set the instance that will be returned by getInstance().
 void setEnabled(boolean state)
          Sets the Logger's logging state.
 void setFilter(Filter filter)
          Give the Logger a Filter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_HANDLERS

public static final java.lang.String LOG_HANDLERS
Description of the Field

LOG_FILTER

public static final java.lang.String LOG_FILTER
Description of the Field

MIN_POOL_SIZE

public static final int MIN_POOL_SIZE
Description of the Field

MAX_POOL_SIZE

public static final int MAX_POOL_SIZE
Description of the Field
Constructor Detail

Logger

public Logger()
Method Detail

setEnabled

public void setEnabled(boolean state)
Sets the Logger's logging state. A true value means the logger will process log requests. A false value means a logger will not process Log requests.
Parameters:
state - true if the logger can currently log something.

setAsync

public void setAsync(boolean async)
Sets the Logger's ability to process logRecords asynchronously. A false value means the logger processes log records synchronously.
Parameters:
async - The new Async value

setFilter

public void setFilter(Filter filter)
Give the Logger a Filter
Parameters:
filter - the Logger's Filter.

getHandlers

public java.util.Iterator getHandlers()
Returns an Iterator for the handlerList.
Returns:
the HandlerList Iterator

isEnabled

public boolean isEnabled()
State of the Logger
Returns:
true if currently accepting log requests.

isAsync

public boolean isAsync()
The method returns true if the logger can process log records asynchronously.
Returns:
true if async

getFilter

public Filter getFilter()
Return the Logger's filter.
Returns:
the Logger's Filter.

addHandler

public void addHandler(Handler handler)
Add a handler to the Logger's list of Handlers. This method does not insure uniqueness.
Parameters:
handler - the handler to add.

removeHandler

public boolean removeHandler(Handler handler)
Remove a handler from the Logger's list of handlers.
Parameters:
handler -  
Returns:
true if the supplied Handler is removed.

log

public abstract void log(java.lang.String rawMessage)
This method is for free form trace-logging where the level is assumed to be Trace and the message text does not represent a lookup key.
Parameters:
rawMessage - the log message text or a log message key.

log

public abstract void log(java.lang.String rawMessage,
                         int level)
This method is for free form logging where a level and the logging message are supplied.
Parameters:
rawMessage - the log message text or a log message key.
level - the Level of importance or urgency

log

public abstract void log(java.lang.String topic,
                         java.lang.String rawMessage,
                         int level)
This method is for free form logging where a level and topic are provided in addition to the logging message.
Parameters:
topic - the topic to which the message pertains
rawMessage - the log message text or a log message key.
level - the level of importance or urgency.

log

public abstract void log(java.lang.String topic,
                         java.lang.String key,
                         java.lang.Object[] insertValues,
                         int level)
This method is used to log by lookup key. If a level and/or Topic are supplied, they will override the level and/or topic of the message that corresponds to the supplied key. It is the job of a Handler to peform a lookup and String substitution (if the looked-up message contains String tokens) using the supplied insertValues. While it is up to a Handler's implementation, in most cases, if the key is not found then the the key is logged as the message. Logging will only be peformed if the Logger is enabled and if the level is not blocked by the Logger's Filtergate.
Parameters:
topic - the topic to which the message pertains
key - the log message's key (as stored in resource bundle)
insertValues - the array of objects used for substitution values.
level - the level of importance or urgency.

log

public abstract void log(java.lang.String key,
                         java.lang.Object[] insertValues)
Deprecated.  

This method is used to trace-log by key. If insertValue objects are supplied, then they will be used for string substitution in the looked up string. The topic will be looked-up in addition the message using the supplied key. The level is assumed to be Trace.
Parameters:
key - the log message's key (as stored in resource bundle)
insertValues - the array of objects used for substitution values.

log

public abstract void log(java.lang.String key,
                         java.lang.Object[] insertValues,
                         int level)
Deprecated.  

This method is used to log by key and level. If insertValue objects are supplied, then they will be used for string substitution in the looked up string. The topic will be looked-up in addition the message using the supplied key.
Parameters:
key - the log message's key (as stored in resource bundle)
insertValues - the array of objects used for substitution values.
level - the level of importance or urgency.

log

public abstract void log(java.lang.Throwable exception,
                         int level)
Log an exception with a level but without a message.
Parameters:
exception - the exception whose stack-trace should be logged.
level - the level of importance or urgency.

log

public abstract void log(java.lang.String rawMessage,
                         java.lang.Throwable exception)
Log a message and exception.
Parameters:
rawMessage - the log message text or a log message key.
exception - the exception whose stack-trace should be logged.

log

public abstract void log(java.lang.String rawMessage,
                         java.lang.Throwable exception,
                         int level)
Log a message, exception and level.
Parameters:
rawMessage - the log message text or a log message key.
exception - the exception whose stack-trace should be logged.
level - the level of importance or urgency.

log

public abstract void log(java.lang.String topic,
                         java.lang.String rawMessage,
                         java.lang.Throwable exception,
                         int level)
Log a message by lookup key. In addition to key, level, topic, insert values and exception must be supplied.
Parameters:
topic - the topic to which the message pertains
exception - the exception whose stack-trace should be logged.
level - the level of importance or urgency.
rawMessage - Description of Parameter

log

public abstract void log(java.lang.String topic,
                         java.lang.String key,
                         java.lang.Object[] insertValues,
                         java.lang.Throwable exception,
                         int level)
Deprecated.  

Log a message by lookup key. In addition to key, level, topic, insert values and exception must be supplied.
Parameters:
topic - the topic to which the message pertains
key - the log message's key (as stored in resource bundle)
insertValues - the array of objects used for substitution values.
exception - the exception whose stack-trace should be logged.
level - the level of importance or urgency.

log

public abstract void log(java.lang.String key,
                         java.lang.Object[] insertValues,
                         java.lang.Throwable exception)
Deprecated.  

Trace-log by key. InsertValues and exception must be supplied.
Parameters:
key - the log message's key (as stored in resource bundle)
insertValues - the array of objects used for substitution values.
exception - the exception whose stack-trace should be logged.

log

public abstract void log(java.lang.String key,
                         java.lang.Object[] insertValues,
                         java.lang.Throwable exception,
                         int level)
Deprecated.  

Log by key and level. In addition, Insert Values and exception must be supplied.
Parameters:
key - the log message's key (as stored in resource bundle)
insertValues - the array of objects used for substitution values.
exception - the exception whose stack-trace should be logged.
level - the level of importance or urgency.

setDefault

public static void setDefault(Logger logger)
Set the instance that will be returned by getInstance().
Parameters:
logger - The new Default value

getInstance

public static Logger getInstance()
This method will attempt to locate a more highly configured logger from the Log Factory. If it is unable to locate a more highly configured logger it will return a singleton instance of the default logger.

Returns:
the current Logger Instance.

getWorkerPool

protected WorkerPool getWorkerPool()
This method returns the Logger's workerPool.
Returns:
a Logger workerPool or null if the pool has not yet been defined.

init

protected void init()
This method performs any Logger initialization.


Copyright © 2001 Resilient Edge, Inc. All Rights Reserved.