Interface ILogger
- Namespace
- Serilog
- Assembly
- Serilog.dll
The core Serilog logging API, used for writing log events.
public interface ILogger
- Extension Methods
Examples
var log = new LoggerConfiguration()
.WriteTo.Console()
.CreateLogger();
var thing = "World";
log.Information("Hello, {Thing}!", thing);
Remarks
The methods on ILogger (and its static sibling Log) are guaranteed never to throw exceptions. Methods on all other types may.
Methods
BindMessageTemplate(string, object?[]?, out MessageTemplate?, out IEnumerable<LogEventProperty>?)
Uses configured scalar conversion and destructuring rules to bind a set of properties to a
message template. Returns false if the template or values are invalid (ILogger
methods never throw exceptions).
[MessageTemplateFormatMethod("messageTemplate")]
bool BindMessageTemplate(string messageTemplate, object?[]? propertyValues, out MessageTemplate? parsedTemplate, out IEnumerable<LogEventProperty>? boundProperties)
Parameters
messageTemplate
stringMessage template describing an event.
propertyValues
object[]Objects positionally formatted into the message template.
parsedTemplate
MessageTemplateThe internal representation of the template, which may be used to render the
boundProperties
as text.boundProperties
IEnumerable<LogEventProperty>Captured properties from the template and
propertyValues
.
Returns
Examples
MessageTemplate template;
IEnumerable<LogEventProperty> properties;
if (Log.BindMessageTemplate("Hello, {Name}!", new[] { "World" }, out template, out properties)
{
var propsByName = properties.ToDictionary(p => p.Name, p => p.Value);
Console.WriteLine(template.Render(propsByName, null));
// -> "Hello, World!"
}
BindProperty(string?, object?, bool, out LogEventProperty?)
Uses configured scalar conversion and destructuring rules to bind a property value to its captured representation.
bool BindProperty(string? propertyName, object? value, bool destructureObjects, out LogEventProperty? property)
Parameters
propertyName
stringThe name of the property. Must be non-empty.
value
objectThe property value.
destructureObjects
boolIf true, the value will be serialized as a structured object if possible; if false, the object will be recorded as a scalar or simple array.
property
LogEventPropertyThe resulting property.
Returns
- bool
True if the property could be bound, otherwise false (
ILogger methods never throw exceptions).
Debug(Exception?, string)
Write a log event with the Debug level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Debug(Exception? exception, string messageTemplate)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
Examples
Log.Debug(ex, "Swallowing a mundane exception.");
Debug(Exception?, string, params object?[]?)
Write a log event with the Debug level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Debug(Exception? exception, string messageTemplate, params object?[]? propertyValues)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValues
object[]Objects positionally formatted into the message template.
Examples
Log.Debug(ex, "Swallowing a mundane exception.");
Debug(string)
Write a log event with the Debug level.
[MessageTemplateFormatMethod("messageTemplate")]
void Debug(string messageTemplate)
Parameters
messageTemplate
stringMessage template describing the event.
Examples
Log.Debug("Starting up at {StartedAt}.", DateTime.Now);
Debug(string, params object?[]?)
Write a log event with the Debug level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Debug(string messageTemplate, params object?[]? propertyValues)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValues
object[]Objects positionally formatted into the message template.
Examples
Log.Debug("Starting up at {StartedAt}.", DateTime.Now);
Debug<T>(Exception?, string, T)
Write a log event with the Debug level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Debug<T>(Exception? exception, string messageTemplate, T propertyValue)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue
TObject positionally formatted into the message template.
Type Parameters
T
Examples
Log.Debug(ex, "Swallowing a mundane exception.");
Debug<T>(string, T)
Write a log event with the Debug level.
[MessageTemplateFormatMethod("messageTemplate")]
void Debug<T>(string messageTemplate, T propertyValue)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue
TObject positionally formatted into the message template.
Type Parameters
T
Examples
Log.Debug("Starting up at {StartedAt}.", DateTime.Now);
Debug<T0, T1>(Exception?, string, T0, T1)
Write a log event with the Debug level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Debug<T0, T1>(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
Type Parameters
T0
T1
Examples
Log.Debug(ex, "Swallowing a mundane exception.");
Debug<T0, T1>(string, T0, T1)
Write a log event with the Debug level.
[MessageTemplateFormatMethod("messageTemplate")]
void Debug<T0, T1>(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
Type Parameters
T0
T1
Examples
Log.Debug("Starting up at {StartedAt}.", DateTime.Now);
Debug<T0, T1, T2>(Exception?, string, T0, T1, T2)
Write a log event with the Debug level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Debug<T0, T1, T2>(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
propertyValue2
T2Object positionally formatted into the message template.
Type Parameters
T0
T1
T2
Examples
Log.Debug(ex, "Swallowing a mundane exception.");
Debug<T0, T1, T2>(string, T0, T1, T2)
Write a log event with the Debug level.
[MessageTemplateFormatMethod("messageTemplate")]
void Debug<T0, T1, T2>(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
propertyValue2
T2Object positionally formatted into the message template.
Type Parameters
T0
T1
T2
Examples
Log.Debug("Starting up at {StartedAt}.", DateTime.Now);
Error(Exception?, string)
Write a log event with the Error level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Error(Exception? exception, string messageTemplate)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
Examples
Log.Error(ex, "Failed {ErrorCount} records.", brokenRecords.Length);
Error(Exception?, string, params object?[]?)
Write a log event with the Error level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Error(Exception? exception, string messageTemplate, params object?[]? propertyValues)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValues
object[]Objects positionally formatted into the message template.
Examples
Log.Error(ex, "Failed {ErrorCount} records.", brokenRecords.Length);
Error(string)
Write a log event with the Error level.
[MessageTemplateFormatMethod("messageTemplate")]
void Error(string messageTemplate)
Parameters
messageTemplate
stringMessage template describing the event.
Examples
Log.Error("Failed {ErrorCount} records.", brokenRecords.Length);
Error(string, params object?[]?)
Write a log event with the Error level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Error(string messageTemplate, params object?[]? propertyValues)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValues
object[]Objects positionally formatted into the message template.
Examples
Log.Error("Failed {ErrorCount} records.", brokenRecords.Length);
Error<T>(Exception?, string, T)
Write a log event with the Error level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Error<T>(Exception? exception, string messageTemplate, T propertyValue)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue
TObject positionally formatted into the message template.
Type Parameters
T
Examples
Log.Error(ex, "Failed {ErrorCount} records.", brokenRecords.Length);
Error<T>(string, T)
Write a log event with the Error level.
[MessageTemplateFormatMethod("messageTemplate")]
void Error<T>(string messageTemplate, T propertyValue)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue
TObject positionally formatted into the message template.
Type Parameters
T
Examples
Log.Error("Failed {ErrorCount} records.", brokenRecords.Length);
Error<T0, T1>(Exception?, string, T0, T1)
Write a log event with the Error level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Error<T0, T1>(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
Type Parameters
T0
T1
Examples
Log.Error(ex, "Failed {ErrorCount} records.", brokenRecords.Length);
Error<T0, T1>(string, T0, T1)
Write a log event with the Error level.
[MessageTemplateFormatMethod("messageTemplate")]
void Error<T0, T1>(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
Type Parameters
T0
T1
Examples
Log.Error("Failed {ErrorCount} records.", brokenRecords.Length);
Error<T0, T1, T2>(Exception?, string, T0, T1, T2)
Write a log event with the Error level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Error<T0, T1, T2>(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
propertyValue2
T2Object positionally formatted into the message template.
Type Parameters
T0
T1
T2
Examples
Log.Error(ex, "Failed {ErrorCount} records.", brokenRecords.Length);
Error<T0, T1, T2>(string, T0, T1, T2)
Write a log event with the Error level.
[MessageTemplateFormatMethod("messageTemplate")]
void Error<T0, T1, T2>(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
propertyValue2
T2Object positionally formatted into the message template.
Type Parameters
T0
T1
T2
Examples
Log.Error("Failed {ErrorCount} records.", brokenRecords.Length);
Fatal(Exception?, string)
Write a log event with the Fatal level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Fatal(Exception? exception, string messageTemplate)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
Examples
Log.Fatal(ex, "Process terminating.");
Fatal(Exception?, string, params object?[]?)
Write a log event with the Fatal level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Fatal(Exception? exception, string messageTemplate, params object?[]? propertyValues)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValues
object[]Objects positionally formatted into the message template.
Examples
Log.Fatal(ex, "Process terminating.");
Fatal(string)
Write a log event with the Fatal level.
[MessageTemplateFormatMethod("messageTemplate")]
void Fatal(string messageTemplate)
Parameters
messageTemplate
stringMessage template describing the event.
Examples
Log.Fatal("Process terminating.");
Fatal(string, params object?[]?)
Write a log event with the Fatal level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Fatal(string messageTemplate, params object?[]? propertyValues)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValues
object[]Objects positionally formatted into the message template.
Examples
Log.Fatal("Process terminating.");
Fatal<T>(Exception?, string, T)
Write a log event with the Fatal level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Fatal<T>(Exception? exception, string messageTemplate, T propertyValue)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue
TObject positionally formatted into the message template.
Type Parameters
T
Examples
Log.Fatal(ex, "Process terminating.");
Fatal<T>(string, T)
Write a log event with the Fatal level.
[MessageTemplateFormatMethod("messageTemplate")]
void Fatal<T>(string messageTemplate, T propertyValue)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue
TObject positionally formatted into the message template.
Type Parameters
T
Examples
Log.Fatal("Process terminating.");
Fatal<T0, T1>(Exception?, string, T0, T1)
Write a log event with the Fatal level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Fatal<T0, T1>(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
Type Parameters
T0
T1
Examples
Log.Fatal(ex, "Process terminating.");
Fatal<T0, T1>(string, T0, T1)
Write a log event with the Fatal level.
[MessageTemplateFormatMethod("messageTemplate")]
void Fatal<T0, T1>(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
Type Parameters
T0
T1
Examples
Log.Fatal("Process terminating.");
Fatal<T0, T1, T2>(Exception?, string, T0, T1, T2)
Write a log event with the Fatal level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Fatal<T0, T1, T2>(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
propertyValue2
T2Object positionally formatted into the message template.
Type Parameters
T0
T1
T2
Examples
Log.Fatal(ex, "Process terminating.");
Fatal<T0, T1, T2>(string, T0, T1, T2)
Write a log event with the Fatal level.
[MessageTemplateFormatMethod("messageTemplate")]
void Fatal<T0, T1, T2>(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
propertyValue2
T2Object positionally formatted into the message template.
Type Parameters
T0
T1
T2
Examples
Log.Fatal("Process terminating.");
ForContext(ILogEventEnricher)
Create a logger that enriches log events via the provided enrichers.
ILogger ForContext(ILogEventEnricher enricher)
Parameters
enricher
ILogEventEnricherEnricher that applies in the context.
Returns
- ILogger
A logger that will enrich log events as specified.
ForContext(IEnumerable<ILogEventEnricher>)
Create a logger that enriches log events via the provided enrichers.
ILogger ForContext(IEnumerable<ILogEventEnricher> enrichers)
Parameters
enrichers
IEnumerable<ILogEventEnricher>Enrichers that apply in the context.
Returns
- ILogger
A logger that will enrich log events as specified.
ForContext(string, object?, bool)
Create a logger that enriches log events with the specified property.
ILogger ForContext(string propertyName, object? value, bool destructureObjects = false)
Parameters
propertyName
stringThe name of the property. Must be non-empty.
value
objectThe property value.
destructureObjects
boolIf true, the value will be serialized as a structured object if possible; if false, the object will be recorded as a scalar or simple array.
Returns
- ILogger
A logger that will enrich log events as specified.
ForContext(Type)
Create a logger that marks log events as being from the specified source type.
ILogger ForContext(Type source)
Parameters
source
TypeType generating log messages in the context.
Returns
- ILogger
A logger that will enrich log events as specified.
ForContext<TSource>()
Create a logger that marks log events as being from the specified source type.
ILogger ForContext<TSource>()
Returns
- ILogger
A logger that will enrich log events as specified.
Type Parameters
TSource
Type generating log messages in the context.
Information(Exception?, string)
Write a log event with the Information level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Information(Exception? exception, string messageTemplate)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
Examples
Log.Information(ex, "Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
Information(Exception?, string, params object?[]?)
Write a log event with the Information level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Information(Exception? exception, string messageTemplate, params object?[]? propertyValues)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValues
object[]Objects positionally formatted into the message template.
Examples
Log.Information(ex, "Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
Information(string)
Write a log event with the Information level.
[MessageTemplateFormatMethod("messageTemplate")]
void Information(string messageTemplate)
Parameters
messageTemplate
stringMessage template describing the event.
Examples
Log.Information("Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
Information(string, params object?[]?)
Write a log event with the Information level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Information(string messageTemplate, params object?[]? propertyValues)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValues
object[]Objects positionally formatted into the message template.
Examples
Log.Information("Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
Information<T>(Exception?, string, T)
Write a log event with the Information level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Information<T>(Exception? exception, string messageTemplate, T propertyValue)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue
TObject positionally formatted into the message template.
Type Parameters
T
Examples
Log.Information(ex, "Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
Information<T>(string, T)
Write a log event with the Information level.
[MessageTemplateFormatMethod("messageTemplate")]
void Information<T>(string messageTemplate, T propertyValue)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue
TObject positionally formatted into the message template.
Type Parameters
T
Examples
Log.Information("Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
Information<T0, T1>(Exception?, string, T0, T1)
Write a log event with the Information level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Information<T0, T1>(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
Type Parameters
T0
T1
Examples
Log.Information(ex, "Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
Information<T0, T1>(string, T0, T1)
Write a log event with the Information level.
[MessageTemplateFormatMethod("messageTemplate")]
void Information<T0, T1>(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
Type Parameters
T0
T1
Examples
Log.Information("Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
Information<T0, T1, T2>(Exception?, string, T0, T1, T2)
Write a log event with the Information level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Information<T0, T1, T2>(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
propertyValue2
T2Object positionally formatted into the message template.
Type Parameters
T0
T1
T2
Examples
Log.Information(ex, "Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
Information<T0, T1, T2>(string, T0, T1, T2)
Write a log event with the Information level.
[MessageTemplateFormatMethod("messageTemplate")]
void Information<T0, T1, T2>(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
propertyValue2
T2Object positionally formatted into the message template.
Type Parameters
T0
T1
T2
Examples
Log.Information("Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
IsEnabled(LogEventLevel)
Determine if events at the specified level will be passed through to the log sinks.
bool IsEnabled(LogEventLevel level)
Parameters
level
LogEventLevelLevel to check.
Returns
Verbose(Exception?, string)
Write a log event with the Verbose level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Verbose(Exception? exception, string messageTemplate)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
Examples
Log.Verbose(ex, "Staring into space, wondering where this comet came from.");
Verbose(Exception?, string, params object?[]?)
Write a log event with the Verbose level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Verbose(Exception? exception, string messageTemplate, params object?[]? propertyValues)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValues
object[]Objects positionally formatted into the message template.
Examples
Log.Verbose(ex, "Staring into space, wondering where this comet came from.");
Verbose(string)
Write a log event with the Verbose level.
[MessageTemplateFormatMethod("messageTemplate")]
void Verbose(string messageTemplate)
Parameters
messageTemplate
stringMessage template describing the event.
Examples
Log.Verbose("Staring into space, wondering if we're alone.");
Verbose(string, params object?[]?)
Write a log event with the Verbose level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Verbose(string messageTemplate, params object?[]? propertyValues)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValues
object[]Objects positionally formatted into the message template.
Examples
Log.Verbose("Staring into space, wondering if we're alone.");
Verbose<T>(Exception?, string, T)
Write a log event with the Verbose level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Verbose<T>(Exception? exception, string messageTemplate, T propertyValue)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue
TObject positionally formatted into the message template.
Type Parameters
T
Examples
Log.Verbose(ex, "Staring into space, wondering where this comet came from.");
Verbose<T>(string, T)
Write a log event with the Verbose level.
[MessageTemplateFormatMethod("messageTemplate")]
void Verbose<T>(string messageTemplate, T propertyValue)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue
TObject positionally formatted into the message template.
Type Parameters
T
Examples
Log.Verbose("Staring into space, wondering if we're alone.");
Verbose<T0, T1>(Exception?, string, T0, T1)
Write a log event with the Verbose level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Verbose<T0, T1>(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
Type Parameters
T0
T1
Examples
Log.Verbose(ex, "Staring into space, wondering where this comet came from.");
Verbose<T0, T1>(string, T0, T1)
Write a log event with the Verbose level.
[MessageTemplateFormatMethod("messageTemplate")]
void Verbose<T0, T1>(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
Type Parameters
T0
T1
Examples
Log.Verbose("Staring into space, wondering if we're alone.");
Verbose<T0, T1, T2>(Exception?, string, T0, T1, T2)
Write a log event with the Verbose level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Verbose<T0, T1, T2>(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
propertyValue2
T2Object positionally formatted into the message template.
Type Parameters
T0
T1
T2
Examples
Log.Verbose(ex, "Staring into space, wondering where this comet came from.");
Verbose<T0, T1, T2>(string, T0, T1, T2)
Write a log event with the Verbose level.
[MessageTemplateFormatMethod("messageTemplate")]
void Verbose<T0, T1, T2>(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
propertyValue2
T2Object positionally formatted into the message template.
Type Parameters
T0
T1
T2
Examples
Log.Verbose("Staring into space, wondering if we're alone.");
Warning(Exception?, string)
Write a log event with the Warning level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Warning(Exception? exception, string messageTemplate)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
Examples
Log.Warning(ex, "Skipped {SkipCount} records.", skippedRecords.Length);
Warning(Exception?, string, params object?[]?)
Write a log event with the Warning level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Warning(Exception? exception, string messageTemplate, params object?[]? propertyValues)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValues
object[]Objects positionally formatted into the message template.
Examples
Log.Warning(ex, "Skipped {SkipCount} records.", skippedRecords.Length);
Warning(string)
Write a log event with the Warning level.
[MessageTemplateFormatMethod("messageTemplate")]
void Warning(string messageTemplate)
Parameters
messageTemplate
stringMessage template describing the event.
Examples
Log.Warning("Skipped {SkipCount} records.", skippedRecords.Length);
Warning(string, params object?[]?)
Write a log event with the Warning level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Warning(string messageTemplate, params object?[]? propertyValues)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValues
object[]Objects positionally formatted into the message template.
Examples
Log.Warning("Skipped {SkipCount} records.", skippedRecords.Length);
Warning<T>(Exception?, string, T)
Write a log event with the Warning level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Warning<T>(Exception? exception, string messageTemplate, T propertyValue)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue
TObject positionally formatted into the message template.
Type Parameters
T
Examples
Log.Warning(ex, "Skipped {SkipCount} records.", skippedRecords.Length);
Warning<T>(string, T)
Write a log event with the Warning level.
[MessageTemplateFormatMethod("messageTemplate")]
void Warning<T>(string messageTemplate, T propertyValue)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue
TObject positionally formatted into the message template.
Type Parameters
T
Examples
Log.Warning("Skipped {SkipCount} records.", skippedRecords.Length);
Warning<T0, T1>(Exception?, string, T0, T1)
Write a log event with the Warning level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Warning<T0, T1>(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
Type Parameters
T0
T1
Examples
Log.Warning(ex, "Skipped {SkipCount} records.", skippedRecords.Length);
Warning<T0, T1>(string, T0, T1)
Write a log event with the Warning level.
[MessageTemplateFormatMethod("messageTemplate")]
void Warning<T0, T1>(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
Type Parameters
T0
T1
Examples
Log.Warning("Skipped {SkipCount} records.", skippedRecords.Length);
Warning<T0, T1, T2>(Exception?, string, T0, T1, T2)
Write a log event with the Warning level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Warning<T0, T1, T2>(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
Parameters
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
propertyValue2
T2Object positionally formatted into the message template.
Type Parameters
T0
T1
T2
Examples
Log.Warning(ex, "Skipped {SkipCount} records.", skippedRecords.Length);
Warning<T0, T1, T2>(string, T0, T1, T2)
Write a log event with the Warning level.
[MessageTemplateFormatMethod("messageTemplate")]
void Warning<T0, T1, T2>(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
Parameters
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
propertyValue2
T2Object positionally formatted into the message template.
Type Parameters
T0
T1
T2
Examples
Log.Warning("Skipped {SkipCount} records.", skippedRecords.Length);
Write(LogEvent)
Write an event to the log.
void Write(LogEvent logEvent)
Parameters
logEvent
LogEventThe event to write.
Write(LogEventLevel, Exception?, string)
Write a log event with the specified level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Write(LogEventLevel level, Exception? exception, string messageTemplate)
Parameters
level
LogEventLevelThe level of the event.
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
Write(LogEventLevel, Exception?, string, params object?[]?)
Write a log event with the specified level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Write(LogEventLevel level, Exception? exception, string messageTemplate, params object?[]? propertyValues)
Parameters
level
LogEventLevelThe level of the event.
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValues
object[]Objects positionally formatted into the message template.
Write(LogEventLevel, string)
Write a log event with the specified level.
[MessageTemplateFormatMethod("messageTemplate")]
void Write(LogEventLevel level, string messageTemplate)
Parameters
level
LogEventLevelThe level of the event.
messageTemplate
stringMessage template describing the event.
Write(LogEventLevel, string, params object?[]?)
Write a log event with the specified level.
[MessageTemplateFormatMethod("messageTemplate")]
void Write(LogEventLevel level, string messageTemplate, params object?[]? propertyValues)
Parameters
level
LogEventLevelThe level of the event.
messageTemplate
stringpropertyValues
object[]
Write<T>(LogEventLevel, Exception?, string, T)
Write a log event with the specified level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Write<T>(LogEventLevel level, Exception? exception, string messageTemplate, T propertyValue)
Parameters
level
LogEventLevelThe level of the event.
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue
TObject positionally formatted into the message template.
Type Parameters
T
Write<T>(LogEventLevel, string, T)
Write a log event with the specified level.
[MessageTemplateFormatMethod("messageTemplate")]
void Write<T>(LogEventLevel level, string messageTemplate, T propertyValue)
Parameters
level
LogEventLevelThe level of the event.
messageTemplate
stringMessage template describing the event.
propertyValue
TObject positionally formatted into the message template.
Type Parameters
T
Write<T0, T1>(LogEventLevel, Exception?, string, T0, T1)
Write a log event with the specified level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Write<T0, T1>(LogEventLevel level, Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
Parameters
level
LogEventLevelThe level of the event.
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
Type Parameters
T0
T1
Write<T0, T1>(LogEventLevel, string, T0, T1)
Write a log event with the specified level.
[MessageTemplateFormatMethod("messageTemplate")]
void Write<T0, T1>(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
Parameters
level
LogEventLevelThe level of the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
Type Parameters
T0
T1
Write<T0, T1, T2>(LogEventLevel, Exception?, string, T0, T1, T2)
Write a log event with the specified level and associated exception.
[MessageTemplateFormatMethod("messageTemplate")]
void Write<T0, T1, T2>(LogEventLevel level, Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
Parameters
level
LogEventLevelThe level of the event.
exception
ExceptionException related to the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
propertyValue2
T2Object positionally formatted into the message template.
Type Parameters
T0
T1
T2
Write<T0, T1, T2>(LogEventLevel, string, T0, T1, T2)
Write a log event with the specified level.
[MessageTemplateFormatMethod("messageTemplate")]
void Write<T0, T1, T2>(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
Parameters
level
LogEventLevelThe level of the event.
messageTemplate
stringMessage template describing the event.
propertyValue0
T0Object positionally formatted into the message template.
propertyValue1
T1Object positionally formatted into the message template.
propertyValue2
T2Object positionally formatted into the message template.
Type Parameters
T0
T1
T2