本文整理汇总了C#中LogEvent.GetMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# LogEvent.GetMetadata方法的具体用法?C# LogEvent.GetMetadata怎么用?C# LogEvent.GetMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogEvent
的用法示例。
在下文中一共展示了LogEvent.GetMetadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRow
private void AddRow(LogEvent singleEvent)
{
var row = new StringBuilder(rowStructure);
var metadataKeys = singleEvent.GetMetadataKeys();
ReplacePlaceholder(ref row, "category", singleEvent.Category);
ReplacePlaceholder(ref row, "timestamp", singleEvent.Timestamp.ToString());
ReplacePlaceholder(ref row, "linenumber", singleEvent.Element.LineNumber.ToString());
foreach (string key in metadataKeys)
{
var values = new List<string>();
var meta = new StringBuilder();
if (singleEvent.GetMetadata(key, out values))
{
foreach (var value in values)
meta.Append(value + "<br>");
}
ReplacePlaceholder(ref row, key, meta.ToString());
}
ReplacePlaceholder(ref row, "element", singleEvent.Element.LogMessage);
table.Append(document.CreateTextNode(Regex.Replace(row.ToString(),"%.*%","n/a")));
}
示例2: WriteTableRow
private void WriteTableRow(LogEvent logEvent)
{
List<string> metadataKeys = logEvent.GetMetadataKeys();
string rowspan = "";
if (metadataKeys.Count > 1)
{
rowspan = " rowspan=" + metadataKeys.Count;
}
this.WriteBeginTag("tr");
this.WriteBeginTag("td", rowspan);
htmlWriter.Write(logEvent.Category);
this.WriteEndTag("td");
this.WriteBeginTag("td", rowspan);
htmlWriter.Write(logEvent.Timestamp);
this.WriteEndTag("td");
this.WriteBeginTag("td", rowspan);
htmlWriter.Write(logEvent.Element.LineNumber);
this.WriteEndTag("td");
this.WriteBeginTag("td");
if (metadataKeys.Count > 0)
{
string key = metadataKeys.ElementAt(0);
string value = "";
List<string> values;
logEvent.GetMetadata(key, out values);
foreach (string metadata in values)
{
value += "<br>" + metadata;
}
htmlWriter.Write(key + ": " + value);
}
this.WriteEndTag("td");
this.WriteBeginTag("td", rowspan);
htmlWriter.Write(logEvent.Element.LogMessage);
this.WriteEndTag("td");
this.WriteEndTag("tr");
for (int i = 1; i < metadataKeys.Count; i++)
{
this.WriteBeginTag("tr");
this.WriteBeginTag("td");
string key = metadataKeys.ElementAt(i);
string value = "";
List<string> values;
logEvent.GetMetadata(key, out values);
foreach (string metadata in values)
{
value += "<br>" + metadata;
}
htmlWriter.Write(key + ": " + value);
this.WriteEndTag("td");
this.WriteEndTag("tr");
}
}