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
loggerILoggerThe logger.
levelLogEventLevelThe log event level used to determine if log is enriched with property.
propertyNamestringThe name of the property. Must be non-empty.
valueTValueThe property value.
destructureObjectsboolIf 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
TValueThe type of the property value.
Exceptions
- ArgumentNullException
When
loggerisnull