Package com.netscape.cms.logging
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.Logger
The mandatory log event typesprotected int
The output buffer size in bytesprotected int
The number of unflushed bytesprotected int
The number of bytes written to the current log fileprotected ConfigStore
protected Date
The date object used for log entriesprotected String
The log date entry format patternprotected File
The log fileprotected String
The log file nameprotected int
The output buffer flush intervalprotected long
The log level threshold Only logs with level greater or equal than this value will be writtenprotected SimpleDateFormat
The log date entry formatprotected SimpleDateFormat
protected boolean
Log signing is on/offprotected BufferedWriter
The log file output streamprotected boolean
The log is turned on/offprotected boolean
Should this log listener self-register or notprotected boolean
protected String
The eventType that this log is triggeredstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
The selected log event typesFields inherited from interface com.netscape.certsrv.base.IExtendedPluginInfo
HELP_TEXT, HELP_TOKEN
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
base64Encode
(byte[] bytes) protected void
close()
Close the log filevoid
deselectEvent
(String event) remove the event from the selected events listprotected void
Synchronized method to write an event to the log file.boolean
eval
(SignedAuditEvent event, netscape.ldap.client.JDAPFilter filter) boolean
eval
(SignedAuditEvent event, netscape.ldap.client.JDAPFilterAnd filter) boolean
eval
(SignedAuditEvent event, netscape.ldap.client.JDAPFilterEqualityMatch filter) boolean
eval
(SignedAuditEvent event, netscape.ldap.client.JDAPFilterNot filter) boolean
eval
(SignedAuditEvent event, netscape.ldap.client.JDAPFilterOr filter) boolean
eval
(SignedAuditEvent event, netscape.ldap.client.JDAPFilterPresent filter) boolean
eval
(SignedAuditEvent event, netscape.ldap.client.JDAPFilterSubString filter) void
void
flush()
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[]
This method returns an array of strings.Returns implementation name.Return list of instance config parameters for this log event listener.long
getLevel()
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.void
init
(ISubsystem owner, ConfigStore config) Initialize this log listenervoid
init
(ConfigStore config) Initialize and open the log using the parameters from a config storevoid
Initialize and open the logvoid
Write an event to the log fileprotected void
open()
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 entriesvoid
replaceEvents
(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.void
selectEvent
(String event) add the event to the selected events listvoid
setFlushInterval
(int flushInterval) Set the flush intervalvoid
shutdown()
Shutdown this log file.void
startup()
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
The mandatory log event types -
selectedEvents
The selected log event types -
filters
The event 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:ILogEventListener
Initialize this log listener- Specified by:
init
in 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:
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 bytesflushInterval
- The interval in seconds to flush the log- Throws:
IOException
ELogException
-
startup
Startup the instance- signed.audit LOGGING_SIGNED_AUDIT_AUDIT_LOG_STARTUP used at audit function startup
- Specified by:
startup
in 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:
flush
in 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:
shutdown
in 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:
log
in 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:
getConfigStore
in 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:
retrieveLogContent
in 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:
retrieveLogList
in interfaceILogEventListener
- Throws:
javax.servlet.ServletException
IOException
EBaseException
-
getImplName
Description copied from interface:ILogEventListener
Returns implementation name.- Specified by:
getImplName
in interfaceILogEventListener
- Returns:
- String name of event listener implementation.
-
getDescription
Description copied from interface:ILogEventListener
Returns the description of this log event listener.- Specified by:
getDescription
in interfaceILogEventListener
- Returns:
- String with listener description.
-
getDefaultParams
Description copied from interface:ILogEventListener
Return list of default config parameters for this log event listener.- Specified by:
getDefaultParams
in interfaceILogEventListener
- Returns:
- Vector of default parameters.
-
getInstanceParams
Description copied from interface:ILogEventListener
Return list of instance config parameters for this log event listener.- Specified by:
getInstanceParams
in interfaceILogEventListener
- Returns:
- Vector of instance parameters.
-
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 interfaceIExtendedPluginInfo
-