Table of Contents

Class LoggerDestructuringConfiguration

Namespace
Serilog.Configuration
Assembly
Serilog.dll

Controls template parameter destructuring configuration.

public class LoggerDestructuringConfiguration
Inheritance
LoggerDestructuringConfiguration
Inherited Members

Methods

AsDictionary<T>()

Capture instances of the specified type as dictionaries. By default, only concrete instantiations of are considered dictionary-like.

public LoggerConfiguration AsDictionary<T>() where T : IDictionary

Returns

LoggerConfiguration

Configuration object allowing method chaining.

Type Parameters

T

Type of dictionary.

AsScalar(Type)

Treat objects of the specified type as scalar values, i.e., don't break them down into properties even when destructuring complex types.

public LoggerConfiguration AsScalar(Type scalarType)

Parameters

scalarType Type

Type to treat as scalar.

Returns

LoggerConfiguration

Configuration object allowing method chaining.

Exceptions

ArgumentNullException

When scalarType is

null

AsScalar<TScalar>()

Treat objects of the specified type as scalar values, i.e., don't break them down into properties even when destructuring complex types.

public LoggerConfiguration AsScalar<TScalar>()

Returns

LoggerConfiguration

Configuration object allowing method chaining.

Type Parameters

TScalar

Type to treat as scalar.

ByTransformingWhere<TValue>(Func<Type, bool>, Func<TValue, object>)

When destructuring objects, transform instances of the specified type with the provided function, if the predicate returns true. Be careful to avoid any intensive work in the predicate, as it can slow down the pipeline significantly.

public LoggerConfiguration ByTransformingWhere<TValue>(Func<Type, bool> predicate, Func<TValue, object> transformation)

Parameters

predicate Func<Type, bool>

A predicate used to determine if the transform applies to a specific type of value

transformation Func<TValue, object>

Function mapping instances of TValue to an alternative representation.

Returns

LoggerConfiguration

Configuration object allowing method chaining.

Type Parameters

TValue

Type of values to transform.

Exceptions

ArgumentNullException

When predicate is

null
ArgumentNullException

When transformation is

null

ByTransforming<TValue>(Func<TValue, object>)

When destructuring objects, transform instances of the specified type with the provided function.

public LoggerConfiguration ByTransforming<TValue>(Func<TValue, object> transformation)

Parameters

transformation Func<TValue, object>

Function mapping instances of TValue to an alternative representation.

Returns

LoggerConfiguration

Configuration object allowing method chaining.

Type Parameters

TValue

Type of values to transform.

Exceptions

ArgumentNullException

When transformation is

null

ToMaximumCollectionCount(int)

When destructuring objects, collections be restricted to specified count thus avoiding bloating payload. Limit is applied to each collection separately, sum of length of collection can exceed limit. Applies limit to all IEnumerable including dictionaries.

public LoggerConfiguration ToMaximumCollectionCount(int maximumCollectionCount)

Parameters

maximumCollectionCount int

Returns

LoggerConfiguration

Configuration object allowing method chaining.

Exceptions

ArgumentOutOfRangeException

When maximumCollectionCount is less than 1

ToMaximumDepth(int)

When destructuring objects, depth will be limited to 10 property traversals deep to guard against ballooning space when recursive/cyclic structures are accidentally passed. To change this limit pass a new maximum depth.

public LoggerConfiguration ToMaximumDepth(int maximumDestructuringDepth)

Parameters

maximumDestructuringDepth int

The maximum depth to use.

Returns

LoggerConfiguration

Configuration object allowing method chaining.

Exceptions

ArgumentOutOfRangeException

When maximumDestructuringDepth is negative

ToMaximumStringLength(int)

When destructuring objects, string values can be restricted to specified length thus avoiding bloating payload. Limit is applied to each value separately, sum of length of strings can exceed limit.

public LoggerConfiguration ToMaximumStringLength(int maximumStringLength)

Parameters

maximumStringLength int

The maximum string length.

Returns

LoggerConfiguration

Configuration object allowing method chaining.

Exceptions

ArgumentOutOfRangeException

When maximumStringLength is less than 2

With(params IDestructuringPolicy[])

When destructuring objects, transform instances with the provided policies.

public LoggerConfiguration With(params IDestructuringPolicy[] destructuringPolicies)

Parameters

destructuringPolicies IDestructuringPolicy[]

Policies to apply when destructuring.

Returns

LoggerConfiguration

Configuration object allowing method chaining.

Exceptions

ArgumentNullException

When destructuringPolicies is

null
ArgumentException

When any element of destructuringPolicies is

null

With<TDestructuringPolicy>()

When destructuring objects, transform instances with the provided policy.

public LoggerConfiguration With<TDestructuringPolicy>() where TDestructuringPolicy : IDestructuringPolicy, new()

Returns

LoggerConfiguration

Configuration object allowing method chaining.

Type Parameters

TDestructuringPolicy

Policy to apply when destructuring.