com.netscape.cms.logging
Class RollingLogFile

java.lang.Object
  extended by com.netscape.cms.logging.LogFile
      extended by com.netscape.cms.logging.RollingLogFile
All Implemented Interfaces:
IExtendedPluginInfo, ILogEventListener, java.util.EventListener

public class RollingLogFile
extends LogFile

A rotating log file for Certificate log events. This class loosely follows the Netscape Common Log API implementing rollover interval, size and file naming conventions. It does not yet implement Disk Usage.

Version:
$Revision: 1706 $, $Date: 2011-01-05 18:02:18 -0800 (Wed, 05 Jan 2011) $

Field Summary
protected  long mExpirationTime
          The amount of time before a backed up log is removed in milliseconds
protected  int mMaxFileSize
          The maximum file size in bytes
protected  long mRolloverInterval
          The amount of time in miniseconds between log rotations
static java.lang.String PROP_EXPIRATION_TIME
           
static java.lang.String PROP_MAX_FILE_SIZE
           
static java.lang.String PROP_ROLLOVER_INTERVAL
           
 
Fields inherited from class com.netscape.cms.logging.LogFile
mBufferSize, mBytesUnflushed, mBytesWritten, mConfig, mDate, mDatePattern, mFile, mFileName, mFlushInterval, mLevel, mLogDateFormat, mLogFileDateFormat, mLogSigning, mLogWriter, mOn, mPid, mRegister, mSelectedEvents, mSelectedEventsList, mSignedAuditLogger, mTrace, mType, PROP_LEVEL, PROP_ON, PROP_REGISTER, PROP_SIGNED_AUDIT_CERT_NICKNAME, PROP_SIGNED_AUDIT_EVENTS, PROP_SIGNED_AUDIT_LOG_SIGNING, PROP_TRACE, PROP_TYPE
 
Fields inherited from interface com.netscape.certsrv.base.IExtendedPluginInfo
HELP_TEXT, HELP_TOKEN
 
Constructor Summary
RollingLogFile()
          Construct a RollingLogFile
 
Method Summary
 long expire(long expirationSeconds)
          Remove any log files which have not been modified in the specified time
protected  java.lang.String[] fileList()
          Get the log file list in the log directory
 java.util.Vector getDefaultParams()
          Return list of default config parameters for this log event listener.
 java.lang.String getDescription()
          Returns the description of this log event listener.
 int getExpirationTime()
          Get the expiration time
 java.lang.String[] getExtendedPluginInfo(java.util.Locale locale)
          This method returns an array of strings.
 java.lang.String getImplName()
          Returns implementation name.
 java.util.Vector getInstanceParams()
          Return list of instance config parameters for this log event listener.
 int getRolloverTime()
          Get the rollover interval
 void init(IConfigStore config)
          Initialize and open a RollingLogFile using the prop config store
 void log(ILogEvent ev)
          Write an event to the log file
 NameValuePairs retrieveLogList(java.util.Hashtable req)
          Retrieve log file list.
protected  void rl_init(int maxFileSize, java.lang.String rolloverInterval, java.lang.String expirationTime)
          Convenience routine to initialized the RollingLogFile specific attributes.
 void rotate()
          Rotate the log file to a backup file with a incrementing integer extension
 void setExpirationTime(java.lang.String expirationSeconds)
          Set the file expiration time
 void setRolloverTime(java.lang.String rolloverSeconds)
          Set the rollover interval
 void shutdown()
          Shutdown this log file.
 void startup()
          Startup the instance
 
Methods inherited from class com.netscape.cms.logging.LogFile
audit, base64Encode, close, deselectEvent, flush, getConfigStore, getLevel, getName, getOn, getType, init, init, log, logEvt2String, open, readEntry, replaceEvents, retrieveLogContent, selectEvent, setFlushInterval, string2Vector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_MAX_FILE_SIZE

public static final java.lang.String PROP_MAX_FILE_SIZE
See Also:
Constant Field Values

PROP_ROLLOVER_INTERVAL

public static final java.lang.String PROP_ROLLOVER_INTERVAL
See Also:
Constant Field Values

PROP_EXPIRATION_TIME

public static final java.lang.String PROP_EXPIRATION_TIME
See Also:
Constant Field Values

mMaxFileSize

protected int mMaxFileSize
The maximum file size in bytes


mRolloverInterval

protected long mRolloverInterval
The amount of time in miniseconds between log rotations


mExpirationTime

protected long mExpirationTime
The amount of time before a backed up log is removed in milliseconds

Constructor Detail

RollingLogFile

public RollingLogFile()
Construct a RollingLogFile

Method Detail

init

public void init(IConfigStore config)
          throws java.io.IOException,
                 EBaseException
Initialize and open a RollingLogFile using the prop config store

Overrides:
init in class LogFile
Parameters:
config - The property config store to find values in
Throws:
java.io.IOException
EBaseException

rl_init

protected void rl_init(int maxFileSize,
                       java.lang.String rolloverInterval,
                       java.lang.String expirationTime)
Convenience routine to initialized the RollingLogFile specific attributes.


startup

public void startup()
             throws EBaseException
Description copied from class: LogFile
Startup the instance

Specified by:
startup in interface ILogEventListener
Overrides:
startup in class LogFile
Throws:
EBaseException - if an internal error occurred

shutdown

public void shutdown()
Shutdown this log file.

Specified by:
shutdown in interface ILogEventListener
Overrides:
shutdown in class LogFile

setRolloverTime

public void setRolloverTime(java.lang.String rolloverSeconds)
Set the rollover interval

Parameters:
rolloverSeconds - The amount of time in seconds until the log is rotated. A value of 0 will disable log rollover.

getRolloverTime

public int getRolloverTime()
Get the rollover interval

Returns:
The interval in seconds in which the log is rotated

setExpirationTime

public void setExpirationTime(java.lang.String expirationSeconds)
Set the file expiration time

Parameters:
expirationSeconds - The amount of time in seconds until log files are deleted

getExpirationTime

public int getExpirationTime()
Get the expiration time

Returns:
The age in seconds in which log files are delete

rotate

public void rotate()
            throws java.io.IOException
Rotate the log file to a backup file with a incrementing integer extension

Throws:
java.io.IOException

expire

public long expire(long expirationSeconds)
            throws ELogException
Remove any log files which have not been modified in the specified time

NOTE: automatic removal of log files is currently NOT supported!

Parameters:
expirationSeconds - The number of seconds since the expired files have been modified.
Returns:
the time in milliseconds when the next file expires
Throws:
ELogException

log

public void log(ILogEvent ev)
         throws ELogException
Write an event to the log file

Specified by:
log in interface ILogEventListener
Overrides:
log in class LogFile
Parameters:
ev - The event to be logged.
Throws:
ELogException

retrieveLogList

public NameValuePairs retrieveLogList(java.util.Hashtable req)
                               throws javax.servlet.ServletException,
                                      java.io.IOException,
                                      EBaseException
Retrieve log file list.

Specified by:
retrieveLogList in interface ILogEventListener
Overrides:
retrieveLogList in class LogFile
Throws:
javax.servlet.ServletException
java.io.IOException
EBaseException

fileList

protected java.lang.String[] fileList()
Get the log file list in the log directory

Returns:
an array of filenames with related path to cert server root

getImplName

public java.lang.String getImplName()
Description copied from interface: ILogEventListener
Returns implementation name.

Specified by:
getImplName in interface ILogEventListener
Overrides:
getImplName in class LogFile
Returns:
String name of event listener implementation.

getDescription

public java.lang.String getDescription()
Description copied from interface: ILogEventListener
Returns the description of this log event listener.

Specified by:
getDescription in interface ILogEventListener
Overrides:
getDescription in class LogFile
Returns:
String with listener description.

getDefaultParams

public java.util.Vector getDefaultParams()
Description copied from interface: ILogEventListener
Return list of default config parameters for this log event listener.

Specified by:
getDefaultParams in interface ILogEventListener
Overrides:
getDefaultParams in class LogFile
Returns:
Vector of default parameters.

getInstanceParams

public java.util.Vector getInstanceParams()
Description copied from interface: ILogEventListener
Return list of instance config parameters for this log event listener.

Specified by:
getInstanceParams in interface ILogEventListener
Overrides:
getInstanceParams in class LogFile
Returns:
Vector of instance parameters.

getExtendedPluginInfo

public java.lang.String[] getExtendedPluginInfo(java.util.Locale locale)
Description copied from interface: IExtendedPluginInfo
This method returns an array of strings. Each element of the array represents a configurable parameter, or some other meta-info (such as help-token) there is an entry indexed on that parameter name ;[,required];;... Where: type_info is either 'string', 'number', 'boolean', 'password' or 'choice(ch1,ch2,ch3,...)' If the marker 'required' is included after the type_info, the parameter will has some visually distinctive marking in the UI. 'description' is a short sentence describing the parameter 'choice' is rendered as a drop-down list. The first parameter in the list will be activated by default 'boolean' is rendered as a checkbox. The resulting parameter will be either 'true' or 'false' 'string' allows any characters 'number' allows only numbers 'password' is rendered as a password field (the characters are replaced with *'s when being types. This parameter is not passed through to the plugin. It is instead inserted directly into the password cache keyed on the instance name. The value of the parameter 'bindPWPrompt' (see example below) is set to the key. In addition to the configurable parameters, the following magic parameters may be defined: HELP_TOKEN;helptoken - a pointer to the online manual section for this plugin HELP_TEXT;helptext - a general help string describing the plugin For example: "username;string;The username you wish to login as" "bindPWPrompt;password;Enter password to bind as above user with" "algorithm;choice(RSA,DSA);Which algorithm do you want to use" "enable;boolean;Do you want to run this plugin" "port;number;Which port number do you want to use"

Specified by:
getExtendedPluginInfo in interface IExtendedPluginInfo
Overrides:
getExtendedPluginInfo in class LogFile