本文整理汇总了C#中NLog.LogEventInfo.GetTags方法的典型用法代码示例。如果您正苦于以下问题:C# LogEventInfo.GetTags方法的具体用法?C# LogEventInfo.GetTags怎么用?C# LogEventInfo.GetTags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NLog.LogEventInfo
的用法示例。
在下文中一共展示了LogEventInfo.GetTags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFromLogEvent
public static EventBuilder CreateFromLogEvent(this ExceptionlessClient client, LogEventInfo ev) {
var contextData = new ContextData(ev.GetContextData());
if (ev.Exception != null)
contextData.SetException(ev.Exception);
var builder = client.CreateEvent(contextData);
if (ev.Exception == null) {
builder.SetSource(ev.LoggerName);
builder.SetProperty(Event.KnownDataKeys.Level, ev.Level.Name);
}
builder.Target.Date = ev.TimeStamp;
if (!String.IsNullOrWhiteSpace(ev.FormattedMessage))
builder.SetMessage(ev.FormattedMessage);
if (ev.Exception != null)
builder.SetSource(ev.LoggerName);
var tagList = ev.GetTags();
if (tagList.Count > 0)
builder.AddTags(tagList.ToArray());
foreach (var p in ev.Properties.Where(kvp => !_ignoredEventProperties.Contains(kvp.Key.ToString(), StringComparer.OrdinalIgnoreCase)))
builder.SetProperty(p.Key.ToString(), p.Value);
return builder;
}
示例2: CreateFromLogEvent
public static EventBuilder CreateFromLogEvent(this ExceptionlessClient client, LogEventInfo ev) {
if (client == null)
throw new ArgumentNullException(nameof(client));
var contextData = new ContextData(ev.GetContextData());
if (ev.Exception != null)
contextData.SetException(ev.Exception);
var builder = client.CreateEvent(contextData);
builder.Target.Date = ev.TimeStamp;
builder.SetSource(ev.LoggerName);
var properties = ev.Properties
.Where(kvp => !_ignoredEventProperties.Contains(kvp.Key.ToString(), StringComparer.OrdinalIgnoreCase))
.ToDictionary(kvp => kvp.Key.ToString(), kvp => kvp.Value, StringComparer.OrdinalIgnoreCase);
object value;
if (properties.TryGetValue("@value", out value)) {
try {
builder.SetValue(Convert.ToDecimal(value));
properties.Remove("@value");
} catch (Exception) {}
}
object stackingKey;
if (properties.TryGetValue(Event.KnownDataKeys.ManualStackingInfo, out stackingKey)) {
try {
builder.SetManualStackingKey(stackingKey.ToString());
properties.Remove(Event.KnownDataKeys.ManualStackingInfo);
} catch (Exception) { }
}
if (ev.Exception == null)
builder.SetProperty(Event.KnownDataKeys.Level, ev.Level.Name);
if (!String.IsNullOrWhiteSpace(ev.FormattedMessage))
builder.SetMessage(ev.FormattedMessage);
var tagList = ev.GetTags();
if (tagList.Count > 0)
builder.AddTags(tagList.ToArray());
foreach (var p in properties)
builder.SetProperty(p.Key, p.Value);
return builder;
}