Table of Contents

Class LoggerExtensions

Namespace
Serilog
Assembly
Serilog.dll

Extends ILogger with additional methods.

public static class LoggerExtensions
Inheritance
LoggerExtensions
Inherited Members

Methods

ForContext<TValue>(ILogger, LogEventLevel, string, TValue, bool)

Create a logger that enriches log events when the specified level is enabled.

public static ILogger ForContext<TValue>(this ILogger logger, LogEventLevel level, string propertyName, TValue value, bool destructureObjects = false)

Parameters

logger ILogger

The logger.

level LogEventLevel

The log event level used to determine if log is enriched with property.

propertyName string

The name of the property. Must be non-empty.

value TValue

The property value.

destructureObjects bool

If 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.

Type Parameters

TValue

The type of the property value.

Exceptions

ArgumentNullException

When logger is

null