<PackageReference Include="Serilog.Sinks.File" Version="8.0.0-dev-02331" />

Serilog.Sinks.File.FileLifecycleHooks

public abstract class FileLifecycleHooks
Enables hooking into log file lifecycle events. Hooks run synchronously and therefore may affect responsiveness of the application if long operations are performed.
protected FileLifecycleHooks()

public virtual void OnFileDeleting(string path)

Called before an obsolete (rolling) log file is deleted. This can be used to copy old logs to an archive location or send to a backup server.

public virtual Stream OnFileOpened(string path, Stream underlyingStream, Encoding encoding)

Initialize or wrap the underlyingStream opened on the log file. This can be used to write file headers, or wrap the stream in another that adds buffering, compression, encryption, etc. The underlying file may or may not be empty when this method is called.

public virtual Stream OnFileOpened(Stream underlyingStream, Encoding encoding)

Initialize or wrap the underlyingStream opened on the log file. This can be used to write file headers, or wrap the stream in another that adds buffering, compression, encryption, etc. The underlying file may or may not be empty when this method is called.

Creates a chain of FileLifecycleHooks that have their methods called sequentially Can be used to compose FileLifecycleHooks together; e.g. add header information to each log file and compress it.