|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opends.server.loggers.MultifileTextWriter
public class MultifileTextWriter
A MultiFileTextWriter is a specialized TextWriter which supports publishing log records to a set of files. MultiFileWriters write to one file in the set at a time, switching files as is dictated by a specified rotation and retention policies. When a switch is required, the writer closes the current file and opens a new one named in accordance with a specified FileNamingPolicy.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.opends.server.loggers.TextWriter |
---|
TextWriter.STDERR, TextWriter.STDOUT, TextWriter.STREAM |
Constructor Summary | |
---|---|
MultifileTextWriter(java.lang.String name,
long interval,
FileNamingPolicy namingPolicy,
FilePermission filePermissions,
LogPublisherErrorHandler errorHandler,
java.lang.String encoding,
boolean autoFlush,
boolean append,
int bufferSize)
Creates a new instance of MultiFileTextWriter with the supplied policies. |
Method Summary | |
---|---|
void |
addRetentionPolicy(RetentionPolicy policy)
Add a retention policy to enforce on the files written by this writer. |
void |
addRotationPolicy(RotationPolicy policy)
Add a rotation policy to enforce on the files written by this writer. |
ConfigChangeResult |
applyConfigurationChange(SizeLimitLogRotationPolicyCfg config)
Applies the configuration changes to this change listener. |
void |
flush()
Flushes any buffered contents of the output stream. |
long |
getBytesWritten()
Retrieves the number of bytes written to the current log file. |
long |
getLastCleanCount()
Retrieves the number of files cleaned in the last cleanup run. |
java.util.Calendar |
getLastCleanTime()
Retrieves the last time one or more log files are cleaned in this instance of the Directory Server. |
java.util.Calendar |
getLastRotationTime()
Retrieves the last time a log file was rotated in this instance of Directory Server. |
FileNamingPolicy |
getNamingPolicy()
Retrieves the current naming policy used to generate log file names. |
java.lang.String |
getShutdownListenerName()
Retrieves the human-readable name for this shutdown listener. |
long |
getTotalFilesCleaned()
Retrieves the total number of files cleaned in this instance of the Directory Server. |
long |
getTotalFilesRotated()
Retrieves the total number file rotations occurred in this instance of the Directory Server. |
boolean |
isConfigurationChangeAcceptable(SizeLimitLogRotationPolicyCfg config,
java.util.List<Message> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable to this change listener. |
void |
processServerShutdown(Message reason)
Indicates that the Directory Server has received a request to stop running and that this shutdown listener should take any action necessary to prepare for it. |
void |
removeAllRetentionPolicies()
Removes all retention policies being enforced by this writer. |
void |
removeAllRotationPolicies()
Removes all the rotation policies currently enforced by this writer. |
void |
rotate()
Tries to rotate the log files. |
void |
setAppend(boolean append)
Set the append setting for this writter. |
void |
setAutoFlush(boolean autoFlush)
Set the auto flush setting for this writer. |
void |
setBufferSize(int bufferSize)
Set the buffer size for this writter. |
void |
setFilePermissions(FilePermission filePermissions)
Set the file permission to set for newly created log files. |
void |
setInterval(long interval)
Set the internval in which the rotator thread checks to see if the log file should be rotated. |
void |
setNamingPolicy(FileNamingPolicy namingPolicy)
Set the naming policy to use when generating new log files. |
void |
setPostRotationActions(java.util.ArrayList<ActionType> actions)
This method sets the actions that need to be executed after rotation. |
void |
shutdown()
Shutdown the text writer. |
void |
writeRecord(java.lang.String record)
Write a log record string to the file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MultifileTextWriter(java.lang.String name, long interval, FileNamingPolicy namingPolicy, FilePermission filePermissions, LogPublisherErrorHandler errorHandler, java.lang.String encoding, boolean autoFlush, boolean append, int bufferSize) throws java.io.IOException, DirectoryException
name
- the name of the log rotation thread.interval
- the interval to check whether the logs need to be rotated.namingPolicy
- the file naming policy to use to name rotated log.
files.filePermissions
- the file permissions to set on the log files.errorHandler
- the log publisher error handler to notify when
an error occurs.encoding
- the encoding to use to write the log files.autoFlush
- whether to flush the writer on every println.append
- whether to append to an existing log file.bufferSize
- the bufferSize to use for the writer.
java.io.IOException
- if an error occurs while creating the log file.
DirectoryException
- if an error occurs while preping the new log
file.Method Detail |
---|
public void addRotationPolicy(RotationPolicy policy)
policy
- The rotation policy to add.public void addRetentionPolicy(RetentionPolicy policy)
policy
- The retention policy to add.public void removeAllRotationPolicies()
public void removeAllRetentionPolicies()
public void setAutoFlush(boolean autoFlush)
autoFlush
- If the writer should flush the buffer after every line.public void setAppend(boolean append)
append
- If the writer should append to an existing file.public void setBufferSize(int bufferSize)
bufferSize
- The size of the underlying output stream buffer.public void setFilePermissions(FilePermission filePermissions)
filePermissions
- The file permission to set for new log files.public FileNamingPolicy getNamingPolicy()
public void setNamingPolicy(FileNamingPolicy namingPolicy)
namingPolicy
- the naming policy to use to name log files.public void setInterval(long interval)
interval
- The interval to check if the log file needs to be rotated.public boolean isConfigurationChangeAcceptable(SizeLimitLogRotationPolicyCfg config, java.util.List<Message> unacceptableReasons)
isConfigurationChangeAcceptable
in interface ConfigurationChangeListener<SizeLimitLogRotationPolicyCfg>
config
- The new configuration containing the changes.unacceptableReasons
- A list that can be used to hold messages about why the
provided configuration is not acceptable.
true
if the proposed change is
acceptable, or false
if it is not.public ConfigChangeResult applyConfigurationChange(SizeLimitLogRotationPolicyCfg config)
applyConfigurationChange
in interface ConfigurationChangeListener<SizeLimitLogRotationPolicyCfg>
config
- The new configuration containing the changes.
public java.lang.String getShutdownListenerName()
getShutdownListenerName
in interface ServerShutdownListener
public void processServerShutdown(Message reason)
processServerShutdown
in interface ServerShutdownListener
reason
- The human-readable reason for the shutdown.public void shutdown()
shutdown
in interface TextWriter
public void writeRecord(java.lang.String record)
writeRecord
in interface TextWriter
record
- the log record to write.public void flush()
flush
in interface TextWriter
public void rotate()
public void setPostRotationActions(java.util.ArrayList<ActionType> actions)
actions
- An array of actions that need to be executed on rotation.public long getBytesWritten()
getBytesWritten
in interface TextWriter
public java.util.Calendar getLastCleanTime()
public long getLastCleanCount()
public java.util.Calendar getLastRotationTime()
public long getTotalFilesRotated()
public long getTotalFilesCleaned()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |