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
ILoggerThe logger.
level
LogEventLevelThe log event level used to determine if log is enriched with property.
propertyName
stringThe name of the property. Must be non-empty.
value
TValueThe property value.
destructureObjects
boolIf 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
isnull