Class FileLogger
- Namespace
- SunamoLogging.FileLogger
- Assembly
- SunamoLogging.dll
File-based logger implementation. Writes either to a fixed file (when logFileName is set)
or to per-day rotating files yyyy-MM-dd_log.txt when logFileName is null/empty.
Format: [ISO timestamp] LEVEL: message on its own line; exceptions append ex.ToString()
on subsequent lines.
public class FileLogger : ILogger
- Inheritance
-
FileLogger
- Implements
- Inherited Members
- Extension Methods
Constructors
FileLogger(string, List<LogLevel>, string?)
File-based logger implementation. Writes either to a fixed file (when logFileName is set)
or to per-day rotating files yyyy-MM-dd_log.txt when logFileName is null/empty.
Format: [ISO timestamp] LEVEL: message on its own line; exceptions append ex.ToString()
on subsequent lines.
public FileLogger(string path, List<LogLevel> levelsToLog, string? logFileName = null)
Parameters
Properties
LevelsToLog
Gets or sets the log levels that should be logged.
public List<LogLevel> LevelsToLog { get; set; }
Property Value
Methods
BeginScope<TState>(TState)
Begins a logical operation scope.
public IDisposable? BeginScope<TState>(TState state) where TState : notnull
Parameters
stateTState
Returns
Type Parameters
TState
IsEnabled(LogLevel)
Determines whether the specified log level is enabled.
public bool IsEnabled(LogLevel logLevel)
Parameters
logLevelLogLevel
Returns
Log<TState>(LogLevel, EventId, TState, Exception?, Func<TState, Exception, string>)
Writes a log entry to the log file.
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception, string> formatter)
Parameters
logLevelLogLeveleventIdEventIdstateTStateexceptionExceptionformatterFunc<TState, Exception, string>
Type Parameters
TState