org.goetz.domino.log4j
Class AbstractAppender

java.lang.Object
  extended byorg.apache.log4j.AppenderSkeleton
      extended byorg.goetz.domino.log4j.AbstractAppender
All Implemented Interfaces:
org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler
Direct Known Subclasses:
AgentAppender, DominoAppender

public abstract class AbstractAppender
extends org.apache.log4j.AppenderSkeleton

This is the base appender for a log4j agent and servlet appender implementation that log to a Domino database using a memory buffer and delayed writing.

Author:
Bernd G?tz

Field Summary
protected  LogDocument doc
           
 
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
 
Constructor Summary
AbstractAppender()
          Creates a new DominoAppender.
 
Method Summary
protected  void addEvent(org.apache.log4j.spi.LoggingEvent event)
          Writes the log entry to the notes document.
 void append(org.apache.log4j.spi.LoggingEvent event)
          Appends the specified event to this DominoAppender.
protected  boolean checkEntryConditions(org.apache.log4j.spi.LoggingEvent event)
          Test if this Appender can append LoggingEvents.
 void close()
          Closes this appender.
 java.lang.String getApplicationName()
          Returns the application name under which the log entries appear.
 java.lang.String getDatabase()
          Returns the databaseName name.
 int getFlushTimeout()
           
 java.lang.String getFormName()
          Returns the form name.
 org.apache.log4j.Layout getLayout()
          Returns the Layout used by this Appender.
protected  lotus.domino.Document getLogDocument(lotus.domino.Database db)
          Returns the Domino Document that the current LoggingEvents should be written to.
 int getMaxLines()
          Sets the internal buffer size.
 java.lang.String getMessage()
          Returns the currently set message.
 java.lang.String getServer()
          Returns the serverName name.
protected abstract  void initialize(org.apache.log4j.spi.LoggingEvent event)
          Initializes application name and path.
protected  java.lang.String replace(java.lang.String s, java.lang.String oldPattern, java.lang.String newPattern)
          Replace a pattern in a string with Java 1.3.
 boolean requiresLayout()
          Always returns false.
 void setApplicationName(java.lang.String appName)
          Sets the name under which the log entries appear.
 void setDatabase(java.lang.String databaseName)
          Sets the databaseName path to log to.
 void setFlushTimeout(int flushTimeout)
           
 void setFormName(java.lang.String formName)
          Sets the form from the log4j properties.
 void setMaxLines(int maxLines)
          Sets the internal buffer size.
 void setMessage(java.lang.String message)
          Reads the message property that contains a pattern converter layout including an additional variable: %u for agent user.
 void setServer(java.lang.String serverName)
          Sets the Domino serverName to log to.
 
Methods inherited from class org.apache.log4j.AppenderSkeleton
activateOptions, addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

doc

protected LogDocument doc
Constructor Detail

AbstractAppender

public AbstractAppender()
Creates a new DominoAppender.

Method Detail

setMessage

public void setMessage(java.lang.String message)
Reads the message property that contains a pattern converter layout including an additional variable: %u for agent user.

Parameters:
message - the pattern layout

getMessage

public java.lang.String getMessage()
Returns the currently set message.


setApplicationName

public void setApplicationName(java.lang.String appName)
Sets the name under which the log entries appear.

Parameters:
appName - application name

getApplicationName

public java.lang.String getApplicationName()
Returns the application name under which the log entries appear.

Returns:
application name

setFormName

public void setFormName(java.lang.String formName)
Sets the form from the log4j properties.


getFormName

public java.lang.String getFormName()
Returns the form name.


setMaxLines

public void setMaxLines(int maxLines)
Sets the internal buffer size.


getMaxLines

public int getMaxLines()
Sets the internal buffer size.


setServer

public void setServer(java.lang.String serverName)
Sets the Domino serverName to log to.

Parameters:
serverName - the server name where the databaseName to log to is on.

getServer

public java.lang.String getServer()
Returns the serverName name.


getDatabase

public java.lang.String getDatabase()
Returns the databaseName name.


setDatabase

public void setDatabase(java.lang.String databaseName)
Sets the databaseName path to log to.

Parameters:
databaseName - the path to the databaseName to log to.

getFlushTimeout

public int getFlushTimeout()

setFlushTimeout

public void setFlushTimeout(int flushTimeout)

requiresLayout

public boolean requiresLayout()
Always returns false. This Appender creates it¥s own SimpleLayout if no Layout is supplied.

Returns:
always false

getLayout

public org.apache.log4j.Layout getLayout()
Returns the Layout used by this Appender.

Returns:
the current Layout.

checkEntryConditions

protected boolean checkEntryConditions(org.apache.log4j.spi.LoggingEvent event)
                                throws lotus.domino.NotesException
Test if this Appender can append LoggingEvents.

Parameters:
event - the LoggingEvent to process.
Returns:
false if the appender is not ready to get LoggingEvents, true otherwise.
Throws:
lotus.domino.NotesException

addEvent

protected void addEvent(org.apache.log4j.spi.LoggingEvent event)
                 throws lotus.domino.NotesException
Writes the log entry to the notes document. A log4j pattern parser is used. In addition %u is supported for user name. Sample: %d %t %u - %m

Parameters:
event - the LoggingEvent to act on.
Throws:
lotus.domino.NotesException - if the Appender could not write to the current Document.

initialize

protected abstract void initialize(org.apache.log4j.spi.LoggingEvent event)
                            throws java.lang.Exception
Initializes application name and path. This is being called only once per appender instance, in contrast to initAppend() and releaseAppend() which are being called each log append call.

Throws:
java.lang.Exception

append

public void append(org.apache.log4j.spi.LoggingEvent event)
Appends the specified event to this DominoAppender. The Logger is responsible for this.

Parameters:
event - the LoggingEvent to append.

getLogDocument

protected lotus.domino.Document getLogDocument(lotus.domino.Database db)
                                        throws lotus.domino.NotesException
Returns the Domino Document that the current LoggingEvents should be written to.

Returns:
the Domino Document to write logs to.
Throws:
lotus.domino.NotesException

close

public void close()
Closes this appender.


replace

protected java.lang.String replace(java.lang.String s,
                                   java.lang.String oldPattern,
                                   java.lang.String newPattern)
Replace a pattern in a string with Java 1.3.

Parameters:
s - is the original String which may contain substring aOldPattern
oldPattern - is the non-empty substring which is to be replaced
newPattern - is the replacement for aOldPattern


Copyright © -2008 . All Rights Reserved.