Table of Contents

Class MessageTemplateFormatMethodAttribute

Namespace
Serilog.Core
Assembly
Serilog.dll

Indicates that the marked method logs data using a message template and (optional) arguments. The name of the parameter which contains the message template should be given in the constructor.

[AttributeUsage(AttributeTargets.Constructor|AttributeTargets.Method)]
public sealed class MessageTemplateFormatMethodAttribute : Attribute
Inheritance
MessageTemplateFormatMethodAttribute
Inherited Members

Examples

[MessageTemplateFormatMethod("messageTemplate")]
public void Information(string messageTemplate, params object[] propertyValues)
{
    // Do something
}

public void Foo()
{
    Information("Hello, {Name}!") // Warning: Nonexistent argument in message template.
}

Constructors

MessageTemplateFormatMethodAttribute(string)

Initializes a new instance of the MessageTemplateFormatMethodAttribute class.

public MessageTemplateFormatMethodAttribute(string messageTemplateParameterName)

Parameters

messageTemplateParameterName string

Name of the message template parameter.

Properties

MessageTemplateParameterName

Gets the name of the message template parameter.

public string MessageTemplateParameterName { get; }

Property Value

string

The name of the message template parameter.