FileAppender ClassApache log4net™ SDK Documentation
Appends logging events to a file.
Inheritance Hierarchy

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

Namespace: log4net.Appender
Assembly: log4net (in log4net.dll) Version: 1.2.15.0 (1.2.15.0)
Syntax

public class FileAppender : TextWriterAppender
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   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 models only hold a write lock while the appender is writing a logging event (FileAppender MinimalLock) or synchronize by using a named system wide Mutex (FileAppender InterProcessLock).

All locking strategies have issues and you should seriously consider using a different strategy that avoids having multiple processes logging to the same file.

See Also