toolbox.services.util.logging.support
Class LoggingServiceAppender

Package class diagram package LoggingServiceAppender
java.lang.Object
  extended by org.apache.log4j.AppenderSkeleton
      extended by toolbox.services.util.logging.support.LoggingServiceAppender
All Implemented Interfaces:
org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler

public class LoggingServiceAppender
extends org.apache.log4j.AppenderSkeleton

An Apache Log4j appender implementation to facilitate interaction with the LoggingService from the log4j logging package.

This appender will publish events to the logging service configured in the environment where this appender is used.

NOTE: This appender only supports logging Levels above Level.INFO.

This appender supports the following configuration options:


Field Summary
 
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
 
Constructor Summary
LoggingServiceAppender()
          Default constructor.
 
Method Summary
 void activateOptions()
          Initialise the appender by obtaining an instance of the configured LoggingService.
 void append(org.apache.log4j.spi.LoggingEvent event)
          Publish the given LoggingEvent to the LoggingService.
protected  boolean checkEntryConditions(org.apache.log4j.spi.LoggingEvent event)
          Check to see whether it is possible to publish the logging event.
 void close()
          Not implemented.
 java.lang.String getDetailDelim()
          Return the delimiter used to split the log record into parts.
 boolean getLocationInfo()
          Return the flag indicating whether LocationInfo must be generated.
 java.lang.String getRegistry()
          Return the name of the Toolbox Service Registry managing the LoggingService.
 java.lang.String getService()
          Return the name of the LoggingService Service instance that must be used.
 boolean requiresLayout()
          This appender does not require a Layout.
 void setDetailDelim(java.lang.String delim)
          Set the delimiter that will be used to split the log record into various parts.
 void setLocationInfo(boolean locationInfo)
          Set flag to indicate whether LocationInfo needs to be generated.
 void setRegistry(java.lang.String regName)
          Set the name of the Toolbox Service Registry managing the LoggingService.
 void setService(java.lang.String svcName)
          Set the name of the LoggingService instance that must be used by this appender.
 
Methods inherited from class org.apache.log4j.AppenderSkeleton
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingServiceAppender

public LoggingServiceAppender()
Default constructor.

Method Detail

setRegistry

public void setRegistry(java.lang.String regName)
Set the name of the Toolbox Service Registry managing the LoggingService.

Parameters:
regName - Name of the ServiceRegistry to use.

setService

public void setService(java.lang.String svcName)
Set the name of the LoggingService instance that must be used by this appender.

Parameters:
svcName - Name of the ServiceRegistry to use.

setLocationInfo

public void setLocationInfo(boolean locationInfo)
Set flag to indicate whether LocationInfo needs to be generated.

Parameters:
locationInfo - boolean indicating whether location info must generated.

setDetailDelim

public void setDetailDelim(java.lang.String delim)
Set the delimiter that will be used to split the log record into various parts.

Parameters:
delim - String containing the delimiter.

getRegistry

public java.lang.String getRegistry()
Return the name of the Toolbox Service Registry managing the LoggingService.

Returns:
String containing the name of the ServiceRegistry to use.

getService

public java.lang.String getService()
Return the name of the LoggingService Service instance that must be used.

Returns:
String containing the name of the LoggingService instance to use.

getLocationInfo

public boolean getLocationInfo()
Return the flag indicating whether LocationInfo must be generated.

Returns:
boolean indicating whether LocationInfo must be generated.

getDetailDelim

public java.lang.String getDetailDelim()
Return the delimiter used to split the log record into parts.

Returns:
String containing the delimiter.

activateOptions

public void activateOptions()
Initialise the appender by obtaining an instance of the configured LoggingService.

Specified by:
activateOptions in interface org.apache.log4j.spi.OptionHandler
Overrides:
activateOptions in class org.apache.log4j.AppenderSkeleton

append

public void append(org.apache.log4j.spi.LoggingEvent event)
Publish the given LoggingEvent to the LoggingService.

This implementation transforms the LoggingEvent into a LogMessage and publishes the LogMessage using the configured LoggingService implementation.

Specified by:
append in class org.apache.log4j.AppenderSkeleton
Parameters:
event - The LoggingEvent to publish.

checkEntryConditions

protected boolean checkEntryConditions(org.apache.log4j.spi.LoggingEvent event)
Check to see whether it is possible to publish the logging event.

Parameters:
event - The LoggingEvent to publish.
Returns:
boolean indicating whether the record should be logged.

requiresLayout

public boolean requiresLayout()
This appender does not require a Layout.

Returns:
false indicating that this appender does not require a layout.

close

public void close()
Not implemented.