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
TType 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
scalarTypeTypeType to treat as scalar.
Returns
- LoggerConfiguration
Configuration object allowing method chaining.
Exceptions
- ArgumentNullException
When
scalarTypeisnull
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
TScalarType 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
predicateFunc<Type, bool>A predicate used to determine if the transform applies to a specific type of value
transformationFunc<TValue, object>Function mapping instances of
TValueto an alternative representation.
Returns
- LoggerConfiguration
Configuration object allowing method chaining.
Type Parameters
TValueType of values to transform.
Exceptions
- ArgumentNullException
When
predicateisnull- ArgumentNullException
When
transformationisnull
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
transformationFunc<TValue, object>Function mapping instances of
TValueto an alternative representation.
Returns
- LoggerConfiguration
Configuration object allowing method chaining.
Type Parameters
TValueType of values to transform.
Exceptions
- ArgumentNullException
When
transformationisnull
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
maximumCollectionCountint
Returns
- LoggerConfiguration
Configuration object allowing method chaining.
Exceptions
- ArgumentOutOfRangeException
When
maximumCollectionCountis 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
maximumDestructuringDepthintThe maximum depth to use.
Returns
- LoggerConfiguration
Configuration object allowing method chaining.
Exceptions
- ArgumentOutOfRangeException
When
maximumDestructuringDepthis 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
maximumStringLengthintThe maximum string length.
Returns
- LoggerConfiguration
Configuration object allowing method chaining.
Exceptions
- ArgumentOutOfRangeException
When
maximumStringLengthis less than 2
With(params IDestructuringPolicy[])
When destructuring objects, transform instances with the provided policies.
public LoggerConfiguration With(params IDestructuringPolicy[] destructuringPolicies)
Parameters
destructuringPoliciesIDestructuringPolicy[]Policies to apply when destructuring.
Returns
- LoggerConfiguration
Configuration object allowing method chaining.
Exceptions
- ArgumentNullException
When
destructuringPoliciesisnull- ArgumentException
When any element of
destructuringPoliciesisnull
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
TDestructuringPolicyPolicy to apply when destructuring.