Apache log4net� SDK Documentation - Microsoft .NET Framework 4.0

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

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

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

Requirements

Namespace: log4net.Appender

Assembly: log4net (in log4net.dll)

See Also

FileAppender Members | log4net.Appender Namespace