log4net SDK Reference

FileAppender Class

Appends logging events to a file.

For a list of all members of this type, see FileAppender Members.

System.Object
   log4net.Appender.AppenderSkeleton
      log4net.Appender.TextWriterAppender
         log4net.Appender.FileAppender
            log4net.Appender.RollingFileAppender

[Visual Basic]
Public Class FileAppender
    Inherits TextWriterAppender
[C#]
public class FileAppender : TextWriterAppender

Thread Safety

This type is not safe for multithreaded operations.

Remarks

Logging events are sent to the file specified by the File property.

The file can be opened in either append or overwrite mode by specifying the AppendToFile property. If the file path is relative it is taken as relative from the application base directory. The file encoding can be specified by setting the Encoding property.

The layout's Header and Footer values will be written each time the file is opened and closed respectively. If the AppendToFile property is true then the file may contain multiple copies of the header and footer.

This 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.

The FileAppender supports pluggable file locking models via the LockingModel property. The default behavior, implemented by FileAppender.ExclusiveLock is to obtain an exclusive write lock on the file until this appender is closed. The alternative model, FileAppender.MinimalLock, only holds a write lock while the appender is writing a logging event.

Requirements

Namespace: log4net.Appender

Assembly: log4net (in log4net.dll)

See Also

FileAppender Members | log4net.Appender Namespace