Appender that rolls log files based on size or date or both.
For a list of all members of this type, see RollingFileAppender Members.
System.Object
log4net.Appender.AppenderSkeleton
log4net.Appender.TextWriterAppender
log4net.Appender.FileAppender
log4net.Appender.RollingFileAppender
This type is not safe for multithreaded operations.
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:
NoteFor 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 true will reduce the number of file renamings to few or none.
CAUTIONChanging 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.
CAUTIONA maximum number of backup files when rolling on date/time boundaries is not supported.
Namespace: log4net.Appender
Assembly: log4net (in log4net.dll)
RollingFileAppender Members | log4net.Appender Namespace