RollingFileAppender extends log4cxx::FileAppender to backup the log files depending on RollingPolicy and TriggeringPolicy .
More...
#include <rollingfileappender.h>
Inheritance diagram for log4cxx::rolling::RollingFileAppender:
Returns the value of the MaxBackupIndex option.
Get the maximum size that the output file is allowed to reach before being rolled over to backup files.
Set the maximum number of backup files to keep around.
Set the maximum size that the output file is allowed to reach before being rolled over to backup files.
The
DatePattern takes a string in the same format as expected by
SimpleDateFormat .
Set option to value.
Activate the options that were previously set with calls to option setters.
Implements the configured roll over behaviour.
The policy that implements the scheme for rolling over a log file.
The policy that determine when to trigger a log file rollover.
Use policy as the scheme for rolling over log files.
Use policy to determine when to trigger a log file rollover.
Close appender.
Get byte length of current active log file.
Increments estimated byte length of current active log file.
The default constructor does not do anything.
Instantiate a
FileAppender and open the file designated by
filename.
Instantiate a
FileAppender and open the file designated by
filename.
Instantiate a
FileAppender and open the file designated by
filename.
The
File property takes a string value which should be the name of the file to append to.
Returns the value of the Append option.
Returns the value of the
File option.
Activate the options that were previously set with calls to option setters.
Set option to value.
Get the value of the BufferedIO option.
Get the size of the IO buffer.
Get the number of seconds between file writes when the BufferedIO option is true.
Set file open mode to newValue.
Set buffered output behavior to newValue.
Use newValue as the size of the output buffer.
Flush the output buffer every newValue seconds.
This default constructor does nothing.
Derived appenders should override this method if option structure requires it.
If the ImmediateFlush option is set to true, the appender will flush at the end of each write.
Returns value of the ImmediateFlush option.
Close this appender instance.
The current encoding value.
Set the encoding to value.
Set option to value.
void
setWriter (const helpers::WriterPtr &writer)
Configurators call this method to determine if the appender requires a layout.
Finalize this appender by calling the derived class' close method.
Activate the options that were previously set with calls to option setters.
Set option to value.
Add a filter to end of the filter list.
Clear the filters chain.
Returns the head Filter.
Return the first filter in the filter chain for this
Appender.
Returns the layout of this appender.
Returns this appenders threshold level.
Check whether the message level is below the appender's threshold.
This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific
AppenderSkeleton::append method.
Set the layout for this appender.
Set the threshold level.
Add a filter to the end of the filter list.
Returns the head Filter.
Clear the list of filters by removing all the filters in it.
Release any resources allocated within the appender such as file handles, network connections, etc.
Get the name of this appender.
Set the
Layout for this appender.
Returns this appenders layout.
Set the name of this appender.
Configurators call this method to determine if the appender requires a layout.
Activate the options that were previously set with calls to option setters.
Set option to value.
virtual const void *
cast (const
Class &clazz) const =0
Protected Member Functions
Actual writing occurs here.
Returns an OutputStreamWriter when passed an OutputStream.
Sets and opens the file where the log output will go.
This method determines if there is a sense in attempting to append.
Returns an OutputStreamWriter when passed an OutputStream.
Actual writing occurs here.
Set the writer.
Subclasses of
AppenderSkeleton should implement this method to perform actual logging.
Additional Inherited Members
Replaces double backslashes with single backslashes for compatibility with paths from earlier XML configurations files.
Detailed Description
RollingFileAppender extends log4cxx::FileAppender to backup the log files depending on RollingPolicy and TriggeringPolicy .
To be of any use, a RollingFileAppender instance must have both a RollingPolicy and a TriggeringPolicy set up. However, if its RollingPolicy also implements the TriggeringPolicy interface, then only the former needs to be set up. For example, TimeBasedRollingPolicy acts both as a RollingPolicy and a TriggeringPolicy .
RollingFileAppender can be configured programattically or using log4cxx::xml::DOMConfigurator . The following is a sample configuration file.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration>
<log4j:configuration debug="true">
<appender name="ROLL" class="org.apache.log4j.rolling.RollingFileAppender">
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="FileNamePattern" value="/wombat/foo.%d{yyyy-MM}.gz"/>
</rollingPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%c{1} - %m%n"/>
</layout>
</appender>
<root>
<appender-ref ref="ROLL"/>
</root>
</log4j:configuration>
This configuration file specifies a monthly rollover schedule including automatic compression of the archived files. See TimeBasedRollingPolicy for more details.
Note: Do not set the option Append to false. Rolling over files is only relevant when you are appending.
Constructor & Destructor Documentation
◆ RollingFileAppender() [1/2]
log4cxx::rolling::RollingFileAppender::RollingFileAppender
(
)
◆ RollingFileAppender() [2/2]
log4cxx::rolling::RollingFileAppender::RollingFileAppender
(
std::unique_ptr< RollingFileAppenderPriv >
priv )
Member Function Documentation
◆ activateOptions()
void log4cxx::rolling::RollingFileAppender::activateOptions
(
helpers::Pool &
pool )
overridevirtual |
◆ close()
void log4cxx::rolling::RollingFileAppender::close
(
)
overridevirtual |
Close appender.
Waits for any asynchronous file compression actions to be completed.
Implements log4cxx::Appender.
◆ createWriter()
helpers::WriterPtr log4cxx::rolling::RollingFileAppender::createWriter
(
LOG4CXX_16_CONST helpers::OutputStreamPtr &
os )
overrideprotectedvirtual |
Returns an OutputStreamWriter when passed an OutputStream.
The encoding used will depend on the value of the encoding property. If the encoding value is specified incorrectly the writer will be opened using the default system encoding (an error message will be printed to the loglog.
- Parameters
-
os output stream, may not be null.
- Returns
- new writer.
Reimplemented from log4cxx::WriterAppender.
◆ getFileLength()
size_t log4cxx::rolling::RollingFileAppender::getFileLength
(
)
const
Get byte length of current active log file.
- Returns
- byte length of current active log file.
◆ getMaxBackupIndex()
int log4cxx::rolling::RollingFileAppender::getMaxBackupIndex
(
)
const
Returns the value of the MaxBackupIndex option.
◆ getMaximumFileSize()
size_t log4cxx::rolling::RollingFileAppender::getMaximumFileSize
(
)
const
Get the maximum size that the output file is allowed to reach before being rolled over to backup files.
◆ getRollingPolicy()
RollingPolicyPtr log4cxx::rolling::RollingFileAppender::getRollingPolicy
(
)
const
The policy that implements the scheme for rolling over a log file.
◆ getTriggeringPolicy()
TriggeringPolicyPtr log4cxx::rolling::RollingFileAppender::getTriggeringPolicy
(
)
const
The policy that determine when to trigger a log file rollover.
◆ incrementFileLength()
void log4cxx::rolling::RollingFileAppender::incrementFileLength
(
size_t
increment )
Increments estimated byte length of current active log file.
- Parameters
-
increment additional bytes written to log file.
◆ makeFileNamePattern()
LogString log4cxx::rolling::RollingFileAppender::makeFileNamePattern
(
const
LogString &
datePattern )
◆ rollover()
Implements the configured roll over behaviour.
If MaxBackupIndex is positive, then files {File.1, ..., File.MaxBackupIndex -1} are renamed to {File.2, ..., File.MaxBackupIndex}. Moreover, File is renamed File.1 and closed. A new File is created to receive further log output.
If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created.
◆ rolloverInternal()
◆ setDatePattern()
void log4cxx::rolling::RollingFileAppender::setDatePattern
(
const
LogString &
pattern )
The DatePattern takes a string in the same format as expected by SimpleDateFormat .
This options determines the rollover schedule.
◆ setMaxBackupIndex()
void log4cxx::rolling::RollingFileAppender::setMaxBackupIndex
(
int
maxBackupIndex )
Set the maximum number of backup files to keep around.
The MaxBackupIndex option determines how many backup files are kept before the oldest is erased. This option takes a positive integer value. If set to zero, then there will be no backup files and the log file will be truncated when it reaches MaxFileSize.
◆ setMaxFileSize()
void log4cxx::rolling::RollingFileAppender::setMaxFileSize
(
const
LogString &
value )
Set the maximum size that the output file is allowed to reach before being rolled over to backup files.
In configuration files, the MaxFileSize option takes an long integer in the range 0 - 2^63. You can specify the value with the suffixes "KB", "MB" or "GB" so that the integer is interpreted being expressed respectively in kilobytes, megabytes or gigabytes. For example, the value "10KB" will be interpreted as 10240.
◆ setMaximumFileSize()
void log4cxx::rolling::RollingFileAppender::setMaximumFileSize
(
size_t
value )
◆ setOption()
void log4cxx::rolling::RollingFileAppender::setOption
(
const
LogString &
option,
)
overridevirtual |
Set option to value.
| Supported options | Supported values | Default value |
| FileDatePattern | (1) | - |
| MaxBackupIndex | 1-12 | 0 |
| MaxFileSize | (2) | 10 MB |
(1) A pattern compatible with java.text.SimpleDateFormat, "ABSOLUTE", "DATE" or "ISO8601". For example, "HH:mm:ss,SSS", "dd MMM yyyy HH:mm:ss,SSS" or "DATE".
(2) An integer in the range 0 - 2^63. You can specify the value with the suffixes "KB", "MB" or "GB" so that the integer is interpreted being expressed respectively in kilobytes, megabytes or gigabytes. For example, the value "10KB" will be interpreted as 10240.
- See also
- FileAppender::setOption()
Reimplemented from log4cxx::FileAppender.
◆ setRollingPolicy()
void log4cxx::rolling::RollingFileAppender::setRollingPolicy
(
const RollingPolicyPtr &
policy )
Use policy as the scheme for rolling over log files.
Where the policy also implements TriggeringPolicy , then policy will be used to determine when to trigger a log file rollover.
◆ setTriggeringPolicy()
void log4cxx::rolling::RollingFileAppender::setTriggeringPolicy
(
const TriggeringPolicyPtr &
policy )
Use policy to determine when to trigger a log file rollover.
◆ subAppend()
)
overrideprotectedvirtual |
The documentation for this class was generated from the following file: