Table of Contents

Class FileAppender.MinimalLock

Namespace
log4net.Appender
Assembly
log4net.dll

Acquires the file lock for each write

public class FileAppender.MinimalLock : FileAppender.LockingModelBase
Inheritance
FileAppender.MinimalLock
Inherited Members

Remarks

Opens the file once for each AcquireLock()/ReleaseLock() cycle, thus holding the lock for the minimal amount of time. This method of locking is considerably slower than FileAppender.ExclusiveLock but allows other processes to move/delete the log file whilst logging continues.

Constructors

MinimalLock()

public MinimalLock()

Methods

AcquireLock()

Acquire the lock on the file

public override Stream AcquireLock()

Returns

Stream

A stream that is ready to be written to.

Remarks

Acquire the lock on the file in preparation for writing to it. Return a stream pointing to the file. ReleaseLock() must be called to release the lock on the output file.

ActivateOptions()

Initializes all resources used by this locking model.

public override void ActivateOptions()

CloseFile()

Close the file

public override void CloseFile()

Remarks

Close the file. No further writes will be made.

OnClose()

Disposes all resources that were initialized by this locking model.

public override void OnClose()

OpenFile(string, bool, Encoding)

Prepares to open the file when the first message is logged.

public override void OpenFile(string filename, bool append, Encoding encoding)

Parameters

filename string

The filename to use

append bool

Whether to append to the file, or overwrite

encoding Encoding

The encoding to use

Remarks

Open the file specified and prepare for logging. No writes will be made until AcquireLock() is called. Must be called before any calls to AcquireLock(), ReleaseLock() and CloseFile().

ReleaseLock()

Release the lock on the file

public override void ReleaseLock()

Remarks

Release the lock on the file. No further writes will be made to the stream until AcquireLock() is called again.