Class LogFile

java.lang.Object
com.netscape.cms.logging.LogFile
All Implemented Interfaces:
IExtendedPluginInfo, ILogEventListener, EventListener
Direct Known Subclasses:
RollingLogFile

public class LogFile extends Object implements ILogEventListener, IExtendedPluginInfo
A log event listener which write logs to log files
Version:
$Revision$, $Date$
  • Field Details

    • logger

      public static org.slf4j.Logger logger
    • PROP_TYPE

      public static final String PROP_TYPE
      See Also:
    • PROP_REGISTER

      public static final String PROP_REGISTER
      See Also:
    • PROP_ON

      public static final String PROP_ON
      See Also:
    • PROP_TRACE

      public static final String PROP_TRACE
      See Also:
    • PROP_SIGNED_AUDIT_LOG_SIGNING

      public static final String PROP_SIGNED_AUDIT_LOG_SIGNING
      See Also:
    • PROP_SIGNED_AUDIT_CERT_NICKNAME

      public static final String PROP_SIGNED_AUDIT_CERT_NICKNAME
      See Also:
    • PROP_SIGNED_AUDIT_SELECTED_EVENTS

      public static final String PROP_SIGNED_AUDIT_SELECTED_EVENTS
      See Also:
    • PROP_SIGNED_AUDIT_MANDATORY_EVENTS

      public static final String PROP_SIGNED_AUDIT_MANDATORY_EVENTS
      See Also:
    • PROP_SIGNED_AUDIT_FILTERS

      public static final String PROP_SIGNED_AUDIT_FILTERS
      See Also:
    • PROP_LEVEL

      public static final String PROP_LEVEL
      See Also:
    • mConfig

      protected ConfigStore mConfig
    • mLogFileDateFormat

      protected SimpleDateFormat mLogFileDateFormat
    • mFile

      protected File mFile
      The log file
    • mFileName

      protected String mFileName
      The log file name
    • mLogWriter

      protected BufferedWriter mLogWriter
      The log file output stream
    • mDatePattern

      protected String mDatePattern
      The log date entry format pattern
    • mLogDateFormat

      protected SimpleDateFormat mLogDateFormat
      The log date entry format
    • mDate

      protected Date mDate
      The date object used for log entries
    • mBytesWritten

      protected int mBytesWritten
      The number of bytes written to the current log file
    • mBufferSize

      protected int mBufferSize
      The output buffer size in bytes
    • mFlushInterval

      protected int mFlushInterval
      The output buffer flush interval
    • mBytesUnflushed

      protected int mBytesUnflushed
      The number of unflushed bytes
    • mandatoryEvents

      protected Set<String> mandatoryEvents
      The mandatory log event types
    • selectedEvents

      protected Set<String> selectedEvents
      The selected log event types
    • filters

      protected Map<String,netscape.ldap.client.JDAPFilter> filters
      The event filters
    • mType

      protected String mType
      The eventType that this log is triggered
    • mOn

      protected boolean mOn
      The log is turned on/off
    • mRegister

      protected boolean mRegister
      Should this log listener self-register or not
    • mTrace

      protected boolean mTrace
    • mLogSigning

      protected boolean mLogSigning
      Log signing is on/off
    • mLevel

      protected long mLevel
      The log level threshold Only logs with level greater or equal than this value will be written
  • Constructor Details

    • LogFile

      public LogFile()
      Constructor for a LogFile.
  • Method Details

    • init

      public void init(ISubsystem owner, ConfigStore config) throws EBaseException
      Description copied from interface: ILogEventListener
      Initialize this log listener
      Specified by:
      init in interface ILogEventListener
      Parameters:
      owner - The subsystem.
      config - Configuration store for this log listener.
      Throws:
      EBaseException
    • selectEvent

      public void selectEvent(String event)
      add the event to the selected events list
      Parameters:
      event - to be selected
    • deselectEvent

      public void deselectEvent(String event)
      remove the event from the selected events list
      Parameters:
      event - to be de-selected
    • replaceEvents

      public void replaceEvents(String events)
      replace the selected events list
      Parameters:
      events - comma-separated event list
    • base64Encode

      public static String base64Encode(byte[] bytes) throws IOException
      Throws:
      IOException
    • init

      public void init(ConfigStore config) throws IOException, EBaseException
      Initialize and open the log using the parameters from a config store
      Parameters:
      config - The property config store to find values in
      Throws:
      IOException
      EBaseException
    • init

      public void init(String fileName, int bufferSize, int flushInterval) throws IOException, ELogException
      Initialize and open the log
      Parameters:
      bufferSize - The buffer size for the output stream in bytes
      flushInterval - The interval in seconds to flush the log
      Throws:
      IOException
      ELogException
    • startup

      public void startup() throws EBaseException
      Startup the instance

      • signed.audit LOGGING_SIGNED_AUDIT_AUDIT_LOG_STARTUP used at audit function startup
      Specified by:
      startup in interface ILogEventListener
      Throws:
      EBaseException - if an internal error occurred
    • getType

      public String getType()
      Retrieves the eventType this log is triggered.
    • getOn

      public String getOn()
      Retrieves the log on/off.
    • getLevel

      public long getLevel()
      Retrieves the log level threshold.
    • getName

      public String getName()
      Retrieves the base log file name.
    • open

      protected void open() throws IOException
      Open the log file. This creates the buffered FileWriter
      Throws:
      IOException
    • flush

      public void flush()
      Flush the log file. Also update the MAC for hash protected logs
      Specified by:
      flush in interface ILogEventListener
    • close

      protected void close()
      Close the log file
    • shutdown

      public void shutdown()
      Shutdown this log file.

      • signed.audit AUDIT_LOG_SHUTDOWN used at audit function shutdown
      Specified by:
      shutdown in interface ILogEventListener
    • setFlushInterval

      public void setFlushInterval(int flushInterval)
      Set the flush interval

      Parameters:
      flushInterval - The amount of time in seconds until the log is flush. A value of 0 will disable autoflush. This will also set the update period for hash protected logs.
    • doLog

      protected void doLog(ILogEvent event) throws ELogException
      Synchronized method to write an event to the log file.
      Parameters:
      event - The log event
      Throws:
      ELogException
    • log

      public void log(ILogEvent ev) throws ELogException
      Write an event to the log file
      Specified by:
      log in interface ILogEventListener
      Parameters:
      ev - The event to be logged.
      Throws:
      ELogException
    • filter

      public void filter(SignedAuditEvent ev) throws ELogException
      Throws:
      ELogException
    • eval

      public boolean eval(SignedAuditEvent event, netscape.ldap.client.JDAPFilter filter)
    • eval

      public boolean eval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterPresent filter)
    • eval

      public boolean eval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterEqualityMatch filter)
    • eval

      public boolean eval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterSubString filter)
    • eval

      public boolean eval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterAnd filter)
    • eval

      public boolean eval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterOr filter)
    • eval

      public boolean eval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterNot filter)
    • logEvt2String

      public String logEvt2String(ILogEvent ev)
    • readEntry

      public Vector<LogEntry> readEntry(int maxLine, int lowLevel, LogSource source, String fName)
      Read all entries whose logLevel >= lowLevel and log source = source to at most maxLine entries(from end) If the parameter is -1, it's ignored and return all entries
      Parameters:
      maxLine - The maximum lines to be returned
      lowLevel - The lowest log level to be returned
      source - The particular log source to be returned
      fName - The log file name to be read. If it's null, read the current log file
    • getConfigStore

      public ConfigStore getConfigStore()
      Retrieves the configuration store of this subsystem.

      Specified by:
      getConfigStore in interface ILogEventListener
      Returns:
      configuration store
    • retrieveLogContent

      public NameValuePairs retrieveLogContent(Hashtable<String,String> req) throws javax.servlet.ServletException, IOException, EBaseException
      Retrieve last "maxLine" number of system log with log lever > "level" and from source "source". If the parameter is omitted. All entries are sent back.
      Specified by:
      retrieveLogContent in interface ILogEventListener
      Parameters:
      req - a Hashtable containing the required information such as log entry, log level, log source, and log name.
      Returns:
      NameValue pair list of log messages.
      Throws:
      javax.servlet.ServletException - For servlet errors.
      IOException - For input/output problems.
      EBaseException - For other problems.
    • retrieveLogList

      public NameValuePairs retrieveLogList(Hashtable<String,String> req) throws javax.servlet.ServletException, IOException, EBaseException
      Retrieve log file list.
      Specified by:
      retrieveLogList in interface ILogEventListener
      Throws:
      javax.servlet.ServletException
      IOException
      EBaseException
    • getImplName

      public String getImplName()
      Description copied from interface: ILogEventListener
      Returns implementation name.
      Specified by:
      getImplName in interface ILogEventListener
      Returns:
      String name of event listener implementation.
    • getDescription

      public String getDescription()
      Description copied from interface: ILogEventListener
      Returns the description of this log event listener.
      Specified by:
      getDescription in interface ILogEventListener
      Returns:
      String with listener description.
    • getDefaultParams

      public Vector<String> getDefaultParams()
      Description copied from interface: ILogEventListener
      Return list of default config parameters for this log event listener.
      Specified by:
      getDefaultParams in interface ILogEventListener
      Returns:
      Vector of default parameters.
    • getInstanceParams

      public Vector<String> getInstanceParams()
      Description copied from interface: ILogEventListener
      Return list of instance config parameters for this log event listener.
      Specified by:
      getInstanceParams in interface ILogEventListener
      Returns:
      Vector of instance parameters.
    • getExtendedPluginInfo

      public String[] getExtendedPluginInfo()
      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 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