<PackageReference Include="NLog" Version="6.1.3" />

NLog.Targets.FileTarget

FileTarget for writing formatted messages to one or more log-files.
public long ArchiveAboveSize { get; set; }

Gets or sets the size in bytes above which log files will be automatically archived. Zero or negative means disabled.

public string ArchiveDateFormat { get; set; }

Gets or sets a value specifying the date format when using ArchiveFileName. Obsolete and only here for Legacy reasons, instead use ArchiveSuffixFormat.

public FileArchivePeriod ArchiveEvery { get; set; }

Gets or sets a value indicating whether to trigger archive operation based on time-period, by moving active-file to file-path specified by ArchiveFileName

public Layout ArchiveFileName { get; set; }

Legacy archive logic where file-archive-logic moves active file to path specified by ArchiveFileName, and then recreates the active file. Use ArchiveSuffixFormat to control suffix format, instead of now obsolete token {#}

public string ArchiveNumbering { get; set; }

Gets or sets the way file archives are numbered. Obsolete and only here for Legacy reasons, instead use ArchiveSuffixFormat.

public bool ArchiveOldFileOnStartup { get; set; }

Gets or sets a value indicating whether any existing log-file should be archived on startup.

public string ArchiveSuffixFormat { get; set; }

Gets or sets the format-string to convert archive sequence-number by using string.Format

public bool AutoFlush { get; set; }

Gets or sets a value indicating whether to automatically flush the file buffers after each log message.

public int BufferSize { get; set; }

Gets or sets the log file buffer size in bytes.

public bool CreateDirs { get; set; }

Gets or sets a value indicating whether to create directories if they do not exist.

public bool DeleteOldFileOnStartup { get; set; }

Gets or sets a value indicating whether to delete old log file on startup.

public bool DiscardAll { get; set; }

Gets or sets whether or not this target should just discard all data that its asked to write. Mostly used for when testing NLog Stack except final write

public bool EnableFileDelete { get; set; }

Gets or sets a value indicating whether to enable log file(s) to be deleted.

public Encoding Encoding { get; set; }

Gets or sets the file encoding.

public Layout FileName { get; set; }

Gets or sets the name of the file to write to.

public bool KeepFileOpen { get; set; }

Gets or sets a value indicating whether to keep log file open instead of opening and closing it on each logging event.

public LineEndingMode LineEnding { get; set; }

Gets or sets the line ending mode.

public int MaxArchiveDays { get; set; }

Gets or sets the maximum days of archive files that should be kept. Zero or negative means disabled.

public int MaxArchiveFiles { get; set; }

Gets or sets the maximum number of archive files that should be kept. Negative means disabled.

public int OpenFileCacheSize { get; set; }

Gets or sets the maximum number of files to be kept open.

public int OpenFileCacheTimeout { get; set; }

Gets or sets the maximum number of seconds that files are kept open. Zero or negative means disabled.

public int OpenFileFlushTimeout { get; set; }

Gets or sets the maximum number of seconds before open files are flushed. Zero or negative means disabled.

public bool ReplaceFileContentsOnEachWrite { get; set; }

Gets or sets a value indicating whether to replace file contents on each write instead of appending log message at the end.

public bool WriteBom { get; set; }

Gets or sets a value indicating whether to write BOM (byte order mark) in created files.

public bool WriteFooterOnArchivingOnly { get; set; }

Gets or sets a value indicating whether the footer should be written only when the file is archived.

public bool WriteHeaderWhenInitialFileNotEmpty { get; set; }

Gets or sets whether to write the Header on initial creation of file appender, even if the file is not empty. Default value is false, which means only write header when initial file is empty (Ex. ensures valid CSV files)

public FileTarget()

Initializes a new instance of the FileTarget class.

public FileTarget(string name)

Initializes a new instance of the FileTarget class.

public static DateTime CalculateNextWeekday(DateTime previousLogEventTimestamp, DayOfWeek dayOfWeek)

Calculate the DateTime of the requested day of the week.

protected virtual Stream CreateFileStream(string filePath, int bufferSize)

Creates stream for appending to the specified filePath

protected virtual void RenderFormattedMessage(LogEventInfo logEvent, StringBuilder target)

Formats the log event for write.