Table of Contents

Class FileLoggerConfiguration

Namespace
Invex.Extensions.Logging.File.Configuration
Assembly
Invex.Extensions.Logging.File.dll

Configuration options for the file logger. Bound from the Logging:File configuration section when registered via AddFile(ILoggingBuilder, bool), and can also be set programmatically via the AddFile(ILoggingBuilder, Action<FileLoggerConfiguration>, bool) overload.

[PublicAPI]
public sealed class FileLoggerConfiguration
Inheritance
FileLoggerConfiguration
Inherited Members

Remarks

Changes made to the bound configuration at runtime (for example, by editing appsettings.json) are picked up automatically and applied to subsequent log writes.

Fields

DefaultFileSizeLimitBytes

The default value of FileSizeLimitBytes: 100 MiB.

public const long DefaultFileSizeLimitBytes = 104857600

Field Value

long

DefaultLogDirectory

The default value of LogDirectory: "Logs".

public const string DefaultLogDirectory = "Logs"

Field Value

string

DefaultLogName

The default value of LogName: null, which means the current application's name (FriendlyName) is used.

public const string? DefaultLogName = null

Field Value

string

DefaultMaxTotalSizeBytes

The default value of MaxTotalSizeBytes: 10 GiB.

public const long DefaultMaxTotalSizeBytes = 10737418240

Field Value

long

DefaultRollingInterval

The default value of RolloverInterval: Day.

public const FileRolloverInterval DefaultRollingInterval = Day

Field Value

FileRolloverInterval

Properties

FileSizeLimitBytes

Gets or sets the maximum size, in bytes, of a single log file. When writing an entry would cause the active file to reach this limit, the file is rolled over (renamed with a timestamp suffix) and a new active file is started. Defaults to DefaultFileSizeLimitBytes (100 MiB).

public long FileSizeLimitBytes { get; set; }

Property Value

long

LogDirectory

Gets or sets the directory where log files are written. May be an absolute path, or a path relative to the application's current working directory. The directory is created automatically if it does not exist. Defaults to DefaultLogDirectory.

public string LogDirectory { get; set; }

Property Value

string

LogName

Gets or sets the base file name (without extension) of the log file. The active log file is named {LogName}.log, and rolled-over files are named {LogName}_{timestamp}.log. When null (the default), the current application's name (FriendlyName) is used.

public string? LogName { get; set; }

Property Value

string

MaxTotalSizeBytes

Gets or sets the maximum combined size, in bytes, of rolled-over log files sharing the same base name. When a rollover occurs and the total size of rolled-over files meets or exceeds this limit, the oldest rolled-over file is deleted. Defaults to DefaultMaxTotalSizeBytes (10 GiB).

public long MaxTotalSizeBytes { get; set; }

Property Value

long

PerLevelLogName

Gets or sets per-LogLevel overrides of the log file name, allowing entries of specific levels to be routed to separate files. For levels present in this dictionary, the mapped name is used in place of LogName; a null value falls back to the application's name. Levels not present use LogName. Empty by default.

public Dictionary<LogLevel, string?> PerLevelLogName { get; set; }

Property Value

Dictionary<LogLevel, string>

RolloverInterval

Gets or sets the time interval after which the active log file is rolled over, based on the file's creation time. Use Infinite to disable time-based rollover. Defaults to DefaultRollingInterval (Day).

public FileRolloverInterval RolloverInterval { get; set; }

Property Value

FileRolloverInterval