Class LoggerConfiguration
- Namespace
- Serilog
- Assembly
- Serilog.dll
Configuration object for creating ILogger instances.
public class LoggerConfiguration
- Inheritance
-
LoggerConfiguration
- Inherited Members
Constructors
LoggerConfiguration()
Construct a LoggerConfiguration.
public LoggerConfiguration()
Properties
AuditTo
Configures sinks for auditing, instead of regular (safe) logging. When auditing is used, exceptions from sinks and any intermediate filters propagate back to the caller. Most callers should use WriteTo instead.
public LoggerAuditSinkConfiguration AuditTo { get; }
Property Value
Remarks
Not all sinks are compatible with transactional auditing requirements (many will use asynchronous batching to improve write throughput and latency). Sinks need to opt-in to auditing support by extending LoggerAuditSinkConfiguration, though the generic Sink(ILogEventSink, LogEventLevel, LoggingLevelSwitch?) method allows any sink class to be adapted for auditing.
Destructure
Configures destructuring of message template parameters.
public LoggerDestructuringConfiguration Destructure { get; }
Property Value
Enrich
Configures enrichment of LogEvents. Enrichers can add, remove and modify the properties associated with events.
public LoggerEnrichmentConfiguration Enrich { get; }
Property Value
Filter
Configures global filtering of LogEvents.
public LoggerFilterConfiguration Filter { get; }
Property Value
MinimumLevel
Configures the minimum level at which events will be passed to sinks. If not specified, only events at the Information level and above will be passed through.
public LoggerMinimumLevelConfiguration MinimumLevel { get; }
Property Value
- LoggerMinimumLevelConfiguration
Configuration object allowing method chaining.
ReadFrom
Apply external settings to the logger configuration.
public LoggerSettingsConfiguration ReadFrom { get; }
Property Value
WriteTo
Configures the sinks that log events will be emitted to.
public LoggerSinkConfiguration WriteTo { get; }
Property Value
Methods
CreateLogger()
Create a logger using the configured sinks, enrichers and minimum level.
public Logger CreateLogger()
Returns
- Logger
The logger.
Remarks
To free resources held by sinks ahead of program shutdown, the returned logger may be cast to IDisposable and disposed.
Exceptions
- InvalidOperationException
When the logger is already created