log4net.AppenderAppenderSkeleton
log4net.AppenderTextWriterAppender
log4net.AppenderFileAppender
log4net.AppenderRollingFileAppender
Namespace: log4net.Appender
Assembly: log4net (in log4net.dll) Version: 2.0.6.0-.NET 4.0
The RollingFileAppender type exposes the following members.
Name | Description | |
---|---|---|
RollingFileAppender |
Initializes a new instance of the RollingFileAppender class.
|
Name | Description | |
---|---|---|
AppendToFile |
Gets or sets a flag that indicates whether the file should be
appended to or overwritten.
(Inherited from FileAppender.) | |
CountDirection |
Gets or sets the rolling file count direction.
| |
DatePattern |
Gets or sets the date pattern to be used for generating file names
when rolling over on date.
| |
DateTimeStrategy |
Gets or sets the strategy for determining the current date and time. The default
implementation is to use LocalDateTime which internally calls through to DateTime.Now.
DateTime.UtcNow may be used on frameworks newer than .NET 1.0 by specifying
UniversalDateTime.
| |
Encoding |
Gets or sets Encoding used to write to the file.
(Inherited from FileAppender.) | |
ErrorHandler |
Gets or set the IErrorHandler and the underlying
QuietTextWriter, if any, for this appender.
(Inherited from TextWriterAppender.) | |
File |
Gets or sets the path to the file that logging will be written to.
(Inherited from FileAppender.) | |
FilterHead |
The filter chain.
(Inherited from AppenderSkeleton.) | |
ImmediateFlush |
Gets or set whether the appender will flush at the end
of each append operation.
(Inherited from TextWriterAppender.) | |
Layout |
Gets or sets the ILayout for this appender.
(Inherited from AppenderSkeleton.) | |
LockingModel |
Gets or sets the LockingModel used to handle locking of the file.
(Inherited from FileAppender.) | |
MaxFileSize |
Gets or sets the maximum size that the output file is allowed to reach
before being rolled over to backup files.
| |
MaximumFileSize |
Gets or sets the maximum size that the output file is allowed to reach
before being rolled over to backup files.
| |
MaxSizeRollBackups |
Gets or sets the maximum number of backup files that are kept before
the oldest is erased.
| |
Name |
Gets or sets the name of this appender.
(Inherited from AppenderSkeleton.) | |
PreserveLogFileNameExtension |
Gets or sets a value indicating whether to preserve the file name extension when rolling.
| |
QuietWriter |
Gets or sets the QuietTextWriter where logging events
will be written to.
(Inherited from TextWriterAppender.) | |
RequiresLayout |
This appender requires a log4net.Layout to be set.
(Inherited from TextWriterAppender.) | |
RollingStyle |
Gets or sets the rolling style.
| |
SecurityContext |
Gets or sets the SecurityContext used to write to the file.
(Inherited from FileAppender.) | |
StaticLogFileName |
Gets or sets a value indicating whether to always log to
the same file.
| |
Threshold |
Gets or sets the threshold Level of this appender.
(Inherited from AppenderSkeleton.) | |
Writer |
Sets the TextWriter where the log output will go.
(Inherited from TextWriterAppender.) |
Name | Description | |
---|---|---|
ActivateOptions |
Initialize the appender based on the options set
(Overrides FileAppenderActivateOptions.) | |
AddFilter |
Adds a filter to the end of the filter chain.
(Inherited from AppenderSkeleton.) | |
AdjustFileBeforeAppend |
Performs any required rolling before outputting the next event
| |
Append(LoggingEvent) |
Write out a logging event.
(Overrides FileAppenderAppend(LoggingEvent).) | |
Append(LoggingEvent) |
Write out an array of logging events.
(Overrides FileAppenderAppend(LoggingEvent).) | |
ClearFilters |
Clears the filter list for this appender.
(Inherited from AppenderSkeleton.) | |
Close |
Closes the appender and release resources.
(Inherited from AppenderSkeleton.) | |
CloseFile |
Closes the previously opened file.
(Inherited from FileAppender.) | |
CloseWriter |
Closes the underlying TextWriter.
(Inherited from FileAppender.) | |
DeleteFile |
Deletes the specified file if it exists.
| |
DoAppend(LoggingEvent) |
Performs threshold checks and invokes filters before
delegating actual logging to the subclasses specific
[M:Append(LoggingEvent)] method.
(Inherited from AppenderSkeleton.) | |
DoAppend(LoggingEvent) |
Performs threshold checks and invokes filters before
delegating actual logging to the subclasses specific
[M:Append(LoggingEvent[])] method.
(Inherited from AppenderSkeleton.) | |
Equals | (Inherited from Object.) | |
ExistingInit |
Initializes based on existing conditions at time of ActivateOptions.
| |
FileExists |
Test if a file exists at a specified path
| |
FilterEvent |
Test if the logging event should we output by this appender
(Inherited from AppenderSkeleton.) | |
Finalize |
Cleans up all resources used by this appender.
(Overrides AppenderSkeletonFinalize.) | |
Flush |
Flushes any buffered log data.
(Inherited from TextWriterAppender.) | |
GetHashCode |
Serves as a hash function for a particular type.
(Inherited from Object.) | |
GetNextOutputFileName |
Get the current output file name
| |
GetType |
Gets the Type of the current instance.
(Inherited from Object.) | |
IsAsSevereAsThreshold |
Checks if the message level is below this appender's threshold.
(Inherited from AppenderSkeleton.) | |
MemberwiseClone |
Creates a shallow copy of the current Object.
(Inherited from Object.) | |
NextCheckDate |
Get the start time of the next window for the current rollpoint
| |
OnClose |
Close this appender instance. The underlying stream or writer is also closed.
(Inherited from FileAppender.) | |
OpenFile |
Creates and opens the file for logging. If StaticLogFileName
is false then the fully qualified name is determined and used.
(Overrides FileAppenderOpenFile(String, Boolean).) | |
PreAppendCheck |
This method determines if there is a sense in attempting to append.
(Inherited from TextWriterAppender.) | |
PrepareWriter |
Called to initialize the file writer
(Inherited from FileAppender.) | |
RenderLoggingEvent(LoggingEvent) |
Renders the LoggingEvent to a string.
(Inherited from AppenderSkeleton.) | |
RenderLoggingEvent(TextWriter, LoggingEvent) |
Renders the LoggingEvent to a string.
(Inherited from AppenderSkeleton.) | |
Reset |
Closes any previously opened file and calls the parent's Reset.
(Inherited from FileAppender.) | |
RollFile |
Renames file fromFile to file toFile.
| |
RollOverRenameFiles |
Implements file roll.
| |
RollOverSize |
Implements file roll base on file size.
| |
RollOverTime |
Rollover the file(s) to date/time tagged file(s).
| |
SafeOpenFile |
Sets and opens the file where the log output will go. The specified file must be writable.
(Inherited from FileAppender.) | |
SetQWForFiles(Stream) |
Sets the quiet writer used for file output
(Inherited from FileAppender.) | |
SetQWForFiles(TextWriter) |
Sets the quiet writer being used.
(Overrides FileAppenderSetQWForFiles(TextWriter).) | |
ToString | (Inherited from Object.) | |
WriteFooter |
Writes a footer as produced by the embedded layout's Footer property.
(Inherited from FileAppender.) | |
WriteFooterAndCloseWriter |
Writes the footer and closes the underlying TextWriter.
(Inherited from TextWriterAppender.) | |
WriteHeader |
Writes a header produced by the embedded layout's Header property.
(Inherited from FileAppender.) |
RollingFileAppender can roll log files based on size or date or both depending on the setting of the RollingStyle property. When set to Size the log file will be rolled once its size exceeds the MaximumFileSize. When set to Date the log file will be rolled once the date boundary specified in the DatePattern property is crossed. When set to Composite the log file will be rolled once the date boundary specified in the DatePattern property is crossed, but within a date boundary the file will also be rolled once its size exceeds the MaximumFileSize. When set to Once the log file will be rolled when the appender is configured. This effectively means that the log file can be rolled once per program execution.
A of few additional optional features have been added:
- Attach date pattern for current log file StaticLogFileName
- Backup number increments for newer files CountDirection
- Infinite number of backups by file size MaxSizeRollBackups
Note |
---|
For large or infinite numbers of backup files a CountDirection greater than zero is highly recommended, otherwise all the backup files need to be renamed each time a new backup is created. When Date/Time based rolling is used setting StaticLogFileName to will reduce the number of file renamings to few or none. |
Caution |
---|
Changing StaticLogFileName or CountDirection without clearing the log file directory of backup files will cause unexpected and unwanted side effects. |
If Date/Time based rolling is enabled this appender will attempt to roll existing files in the directory without a Date/Time tag based on the last write date of the base log file. The appender only rolls the log file when a message is logged. If Date/Time based rolling is enabled then the appender will not roll the log file at the Date/Time boundary but at the point when the next message is logged after the boundary has been crossed.
The RollingFileAppender extends the FileAppender and has the same behavior when opening the log file. The appender will first try to open the file for writing when ActivateOptions is called. This will typically be during configuration. If the file cannot be opened for writing the appender will attempt to open the file again each time a message is logged to the appender. If the file cannot be opened for writing when a message is logged then the message will be discarded by this appender.
When rolling a backup file necessitates deleting an older backup file the file to be deleted is moved to a temporary name before being deleted.
Caution |
---|
A maximum number of backup files when rolling on date/time boundaries is not supported. |