Click or drag to resize

FileLifecycleHooksOnFileOpened Method

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.

Namespace:  NLog.Targets
Assembly:  NLog (in NLog.dll) Version: 6.0.0+cfb73701cda54e2410b006f649f072e90daef707
Syntax
public virtual Stream OnFileOpened(
	string filePath,
	Stream underlyingStream
)

Parameters

filePath
Type: SystemString
The full path to the log file.
underlyingStream
Type: System.IOStream
The underlying Stream opened on the log file.

Return Value

Type: Stream
The Stream NLog should use when writing events to the log file.
Remarks

The underlying file may or may not be empty when this method is called.

NLog takes ownership of the returned stream and disposes it when the file is closed. If the returned stream wraps underlyingStream, the returned stream is responsible for disposing the underlying stream.

See Also