Click or drag to resize

FileLifecycleHooksOnFileDeleting Method

Called immediately before a log file is deleted by the FileTarget.

Namespace:  NLog.Targets
Assembly:  NLog (in NLog.dll) Version: 6.0.0+cfb73701cda54e2410b006f649f072e90daef707
Syntax
public virtual void OnFileDeleting(
	string filePath
)

Parameters

filePath
Type: SystemString
The full path to the file that is about to be deleted.
Remarks

This is a per-file event and can be used to perform custom actions before NLog deletes the file as part of its file cleanup logic, for example when MaxArchiveFiles or MaxArchiveDays triggers archive cleanup.

It is possible to move, rename, or delete the file in this method, as FileTarget silently ignores that the file is already gone.

See Also