SimpleFileFormatter Class

A FileFormatter that writes one human-readable line per log entry.

public sealed class SimpleFileFormatter : FileFormatter
Inheritance
FileFormatter SimpleFileFormatter

Constructors

NameDescription
SimpleFileFormatter()Initializes a new instance of the SimpleFileFormatter class.

SimpleFileFormatter()

SimpleFileFormatter.cs

Initializes a new instance of the SimpleFileFormatter class.

public SimpleFileFormatter()

Properties

NameDescription
InstanceGets a shared instance of the SimpleFileFormatter class.

Gets a shared instance of the SimpleFileFormatter class.

public static SimpleFileFormatter Instance { get; }

Property value

SimpleFileFormatter

Methods

NameDescription
Write<TState>(LogEntry<TState>, DateTimeOffset, FileLoggerOptions, IExternalScopeProvider?, TextWriter)Writes the log message to the specified TextWriter. The line terminator is written by the provider.

Write<TState>(LogEntry<TState>, DateTimeOffset, FileLoggerOptions, IExternalScopeProvider?, TextWriter)

SimpleFileFormatter.cs

Writes the log message to the specified TextWriter. The line terminator is written by the provider.

public override void Write<TState>(in LogEntry<TState> logEntry, DateTimeOffset timestamp, FileLoggerOptions options, IExternalScopeProvider? scopeProvider, TextWriter textWriter)

Type parameters

TState
The type of the log entry state.

Parameters

logEntry LogEntry<TState>
The log entry to write.
timestamp DateTimeOffset
The date and time at which the message was logged, in the timezone configured by FileLoggerOptions.UseUtcTimestamp.
options FileLoggerOptions
The options of the provider that created the log entry.
scopeProvider IExternalScopeProvider?
The provider of scope data, or null when the scopes must not be written.
textWriter TextWriter
The writer the message must be written to.

Remarks

The method is called on the thread that logs the message, so the ambient state such as Activity.Current can be read.