当前位置: 首页>>代码示例>>C#>>正文


C# LogEvent.GetMetadataKeys方法代码示例

本文整理汇总了C#中LogEvent.GetMetadataKeys方法的典型用法代码示例。如果您正苦于以下问题:C# LogEvent.GetMetadataKeys方法的具体用法?C# LogEvent.GetMetadataKeys怎么用?C# LogEvent.GetMetadataKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LogEvent的用法示例。


在下文中一共展示了LogEvent.GetMetadataKeys方法的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")));
        }
开发者ID:mk83ko,项目名称:any-log-analyzer,代码行数:22,代码来源:HtmlReportGenerator.cs

示例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");
            }
        }
开发者ID:mk83ko,项目名称:any-log-analyzer,代码行数:63,代码来源:SimpleHtmlReportGenerator.cs


注:本文中的LogEvent.GetMetadataKeys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。