Table of Contents

Class PropertyToken

Namespace
Serilog.Parsing
Assembly
Serilog.dll

A message template token representing a log event property.

public sealed class PropertyToken : MessageTemplateToken
Inheritance
PropertyToken
Inherited Members

Constructors

PropertyToken(string, string, string?, in Alignment?, Destructuring)

Construct a PropertyToken.

public PropertyToken(string propertyName, string rawText, string? format = null, in Alignment? alignment = null, Destructuring destructuring = Destructuring.Default)

Parameters

propertyName string

The name of the property.

rawText string

The token as it appears in the message template.

format string

The format applied to the property, if any.

alignment Alignment?

The alignment applied to the property, if any.

destructuring Destructuring

The destructuring strategy applied to the property, if any.

Exceptions

ArgumentNullException

When propertyName is

null
ArgumentNullException

When rawText is

null

Properties

Alignment

Alignment applied to the property.

public Alignment? Alignment { get; }

Property Value

Alignment?

Destructuring

Destructuring strategy applied to the property.

public Destructuring Destructuring { get; }

Property Value

Destructuring

Format

Format applied to the property.

public string? Format { get; }

Property Value

string

IsPositional

true if the property name is a positional index; otherwise, false.

public bool IsPositional { get; }

Property Value

bool

Length

The token's length.

public override int Length { get; }

Property Value

int

PropertyName

The property name.

public string PropertyName { get; }

Property Value

string

Methods

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Serves as a hash function for a particular type.

public override int GetHashCode()

Returns

int

A hash code for the current object.

Render(IReadOnlyDictionary<string, LogEventPropertyValue>, TextWriter, IFormatProvider?)

Render the token to the output.

public override void Render(IReadOnlyDictionary<string, LogEventPropertyValue> properties, TextWriter output, IFormatProvider? formatProvider = null)

Parameters

properties IReadOnlyDictionary<string, LogEventPropertyValue>

Properties that may be represented by the token.

output TextWriter

Output for the rendered string.

formatProvider IFormatProvider

Supplies culture-specific formatting information, or null.

Exceptions

ArgumentNullException

When properties is

null
ArgumentNullException

When output is

null

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

TryGetPositionalValue(out int)

Try to get the integer value represented by the property name.

public bool TryGetPositionalValue(out int position)

Parameters

position int

The integer value, if present.

Returns

bool

True if the property is positional, otherwise false.