Class LogFile
java.lang.Object
com.netscape.cms.logging.LogFile
- All Implemented Interfaces:
IExtendedPluginInfo,ILogEventListener,EventListener
- Direct Known Subclasses:
RollingLogFile
A log event listener which write logs to log files
- Version:
- $Revision$, $Date$
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe event filtersstatic org.slf4j.LoggerThe mandatory log event typesprotected intThe output buffer size in bytesprotected intThe number of unflushed bytesprotected intThe number of bytes written to the current log fileprotected IConfigStoreprotected DateThe date object used for log entriesprotected StringThe log date entry format patternprotected FileThe log fileprotected StringThe log file nameprotected intThe output buffer flush intervalprotected longThe log level threshold Only logs with level greater or equal than this value will be writtenprotected SimpleDateFormatThe log date entry formatprotected SimpleDateFormatprotected booleanLog signing is on/offprotected BufferedWriterThe log file output streamprotected booleanThe log is turned on/offprotected booleanShould this log listener self-register or notprotected booleanprotected StringThe eventType that this log is triggeredstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe selected log event typesFields inherited from interface com.netscape.certsrv.base.IExtendedPluginInfo
HELP_TEXT, HELP_TOKEN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringbase64Encode(byte[] bytes) protected voidclose()Close the log filevoiddeselectEvent(String event) remove the event from the selected events listprotected voidSynchronized method to write an event to the log file.booleaneval(SignedAuditEvent event, netscape.ldap.client.JDAPFilter filter) booleaneval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterAnd filter) booleaneval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterEqualityMatch filter) booleaneval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterNot filter) booleaneval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterOr filter) booleaneval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterPresent filter) booleaneval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterSubString filter) voidvoidflush()Flush the log file.Retrieves the configuration store of this subsystem.Return list of default config parameters for this log event listener.Returns the description of this log event listener.String[]getExtendedPluginInfo(Locale locale) This method returns an array of strings.Returns implementation name.Return list of instance config parameters for this log event listener.longgetLevel()Retrieves the log level threshold.getName()Retrieves the base log file name.getOn()Retrieves the log on/off.getType()Retrieves the eventType this log is triggered.voidinit(IConfigStore config) Initialize and open the log using the parameters from a config storevoidinit(ISubsystem owner, IConfigStore config) Initialize this log listenervoidInitialize and open the logvoidWrite an event to the log fileprotected voidopen()Open the log file.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 entriesvoidreplaceEvents(String events) replace the selected events listRetrieve last "maxLine" number of system log with log lever > "level" and from source "source".retrieveLogList(Hashtable<String, String> req) Retrieve log file list.voidselectEvent(String event) add the event to the selected events listvoidsetFlushInterval(int flushInterval) Set the flush intervalvoidshutdown()Shutdown this log file.voidstartup()Startup the instance
-
Field Details
-
logger
public static org.slf4j.Logger logger -
PROP_TYPE
- See Also:
-
PROP_REGISTER
- See Also:
-
PROP_ON
- See Also:
-
PROP_TRACE
- See Also:
-
PROP_SIGNED_AUDIT_LOG_SIGNING
- See Also:
-
PROP_SIGNED_AUDIT_CERT_NICKNAME
- See Also:
-
PROP_SIGNED_AUDIT_SELECTED_EVENTS
- See Also:
-
PROP_SIGNED_AUDIT_MANDATORY_EVENTS
- See Also:
-
PROP_SIGNED_AUDIT_FILTERS
- See Also:
-
PROP_LEVEL
- See Also:
-
mConfig
-
mLogFileDateFormat
-
mFile
The log file -
mFileName
The log file name -
mLogWriter
The log file output stream -
mDatePattern
The log date entry format pattern -
mLogDateFormat
The log date entry format -
mDate
The date object used for log entries -
mBytesWritten
protected int mBytesWrittenThe number of bytes written to the current log file -
mBufferSize
protected int mBufferSizeThe output buffer size in bytes -
mFlushInterval
protected int mFlushIntervalThe output buffer flush interval -
mBytesUnflushed
protected int mBytesUnflushedThe number of unflushed bytes -
mandatoryEvents
-
selectedEvents
-
filters
-
mType
The eventType that this log is triggered -
mOn
protected boolean mOnThe log is turned on/off -
mRegister
protected boolean mRegisterShould this log listener self-register or not -
mTrace
protected boolean mTrace -
mLogSigning
protected boolean mLogSigningLog signing is on/off -
mLevel
protected long mLevelThe 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
Description copied from interface:ILogEventListenerInitialize this log listener- Specified by:
initin interfaceILogEventListener- Parameters:
owner- The subsystem.config- Configuration store for this log listener.- Throws:
EBaseException
-
selectEvent
add the event to the selected events list- Parameters:
event- to be selected
-
deselectEvent
remove the event from the selected events list- Parameters:
event- to be de-selected
-
replaceEvents
replace the selected events list- Parameters:
events- comma-separated event list
-
base64Encode
- Throws:
IOException
-
init
Initialize and open the log using the parameters from a config store- Parameters:
config- The property config store to find values in- Throws:
IOExceptionEBaseException
-
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 bytesflushInterval- The interval in seconds to flush the log- Throws:
IOExceptionELogException
-
startup
Startup the instance- signed.audit LOGGING_SIGNED_AUDIT_AUDIT_LOG_STARTUP used at audit function startup
- Specified by:
startupin interfaceILogEventListener- Throws:
EBaseException- if an internal error occurred
-
getType
Retrieves the eventType this log is triggered. -
getOn
Retrieves the log on/off. -
getLevel
public long getLevel()Retrieves the log level threshold. -
getName
Retrieves the base log file name. -
open
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:
flushin interfaceILogEventListener
-
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:
shutdownin interfaceILogEventListener
-
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
Synchronized method to write an event to the log file.- Parameters:
event- The log event- Throws:
ELogException
-
log
Write an event to the log file- Specified by:
login interfaceILogEventListener- Parameters:
ev- The event to be logged.- Throws:
ELogException
-
filter
- Throws:
ELogException
-
eval
-
eval
-
eval
-
eval
-
eval
-
eval
-
eval
-
logEvt2String
-
readEntry
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 returnedlowLevel- The lowest log level to be returnedsource- The particular log source to be returnedfName- The log file name to be read. If it's null, read the current log file
-
getConfigStore
Retrieves the configuration store of this subsystem.- Specified by:
getConfigStorein interfaceILogEventListener- Returns:
- configuration store
-
retrieveLogContent
public NameValuePairs retrieveLogContent(Hashtable<String, String> req) throws javax.servlet.ServletException, IOException, EBaseExceptionRetrieve 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:
retrieveLogContentin interfaceILogEventListener- 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, EBaseExceptionRetrieve log file list.- Specified by:
retrieveLogListin interfaceILogEventListener- Throws:
javax.servlet.ServletExceptionIOExceptionEBaseException
-
getImplName
Description copied from interface:ILogEventListenerReturns implementation name.- Specified by:
getImplNamein interfaceILogEventListener- Returns:
- String name of event listener implementation.
-
getDescription
Description copied from interface:ILogEventListenerReturns the description of this log event listener.- Specified by:
getDescriptionin interfaceILogEventListener- Returns:
- String with listener description.
-
getDefaultParams
Description copied from interface:ILogEventListenerReturn list of default config parameters for this log event listener.- Specified by:
getDefaultParamsin interfaceILogEventListener- Returns:
- Vector of default parameters.
-
getInstanceParams
Description copied from interface:ILogEventListenerReturn list of instance config parameters for this log event listener.- Specified by:
getInstanceParamsin interfaceILogEventListener- Returns:
- Vector of instance parameters.
-
getExtendedPluginInfo
Description copied from interface:IExtendedPluginInfoThis 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:
getExtendedPluginInfoin interfaceIExtendedPluginInfo
-