Click or drag to resize

FileLifecycleHooks Class

Enables hooking into file and FileTarget lifecycle events. Hooks are invoked synchronously and therefore may affect application responsiveness if they perform long-running operations.
Inheritance Hierarchy
SystemObject
  NLog.TargetsFileLifecycleHooks

Namespace:  NLog.Targets
Assembly:  NLog (in NLog.dll) Version: 6.0.0+cfb73701cda54e2410b006f649f072e90daef707
Syntax
public abstract class FileLifecycleHooks

The FileLifecycleHooks type exposes the following members.

Constructors
  NameDescription
Protected methodFileLifecycleHooks
Initializes a new instance of the FileLifecycleHooks class
Top
Methods
  NameDescription
Public methodOnFileClosed
Called after a log file has been closed by the FileTarget.
Public methodOnFileDeleting
Called immediately before a log file is deleted by the FileTarget.
Public methodOnFileOpened
Initializes or wraps the stream opened for a log file. This can be used to write file headers, or wrap the stream in another stream that adds buffering, compression, encryption, etc.
Public methodOnTargetClose
Called when the FileTarget is being closed.
Public methodOnTargetInitialize
Called when the FileTarget is initialized.
Top
Remarks

A FileTarget can have multiple log files open simultaneously. File lifecycle callbacks therefore apply to the individual file identified by filePath and must not assume that there is only one active file.

The same file may be opened and closed multiple times during the lifetime of a FileTarget.

See Also