本文整理汇总了C#中ILogger.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.SetProperty方法的具体用法?C# ILogger.SetProperty怎么用?C# ILogger.SetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.SetProperty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogOperation
public LogOperation(ILogger logger, string value)
{
Logger = logger;
PreviousValue = Logger.GetProperty(LogContext.PropertyKey.Operation);
// set the new key/value
if (PreviousValue.HasValue())
{
Logger.SetProperty(LogContext.PropertyKey.Operation, PreviousValue + "." + value);
}
else
{
Logger.SetProperty(LogContext.PropertyKey.Operation, value);
}
}
示例2: Clear
/// <summary>
/// Clear log context.
/// </summary>
internal static void Clear(ILogger logger)
{
foreach (var field in PropertyKey.Fields)
{
var key = field.GetValue(DummyLogContext) as string;
logger.SetProperty(key, null);
}
}
示例3: Set
/// <summary>
/// Set all log context values from this LogContext object to logger.
/// </summary>
internal void Set(ILogger logger)
{
if (Properties == null)
{
return;
}
foreach (var propertyKeyField in PropertyKey.Fields)
{
var propertyKey = propertyKeyField.GetValue(DummyLogContext) as string;
if (propertyKey != null && Properties.ContainsKey(propertyKey))
{
var propertyValue = Properties[propertyKey];
logger.SetProperty(propertyKey, propertyValue);
}
}
}
示例4: LogProps
private LogProps(ILogger logger, string propertyName, object propertyValue)
{
this.logger = logger;
this.propertyName = propertyName;
logger.SetProperty(propertyName, propertyValue);
}