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


C# EventTextFormatter.WriteEvent方法代码示例

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


在下文中一共展示了EventTextFormatter.WriteEvent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WritingToANullWriterThrows

 public void WritingToANullWriterThrows()
 {
     var formatter = new EventTextFormatter();
     formatter.WriteEvent(new EventEntry(Guid.NewGuid(), 0, string.Empty, new System.Collections.ObjectModel.ReadOnlyCollection<object>(new object[0]), DateTimeOffset.MaxValue, new EventSourceSchemaReader().GetSchema(Logger).Values.First()), null);
 }
开发者ID:EdHastings,项目名称:semantic-logging,代码行数:5,代码来源:EventTextFormatterTests.cs

示例2: WritingNullEntryThrows

 public void WritingNullEntryThrows()
 {
     var formatter = new EventTextFormatter();
     using (var writer = new StringWriter())
     {
         formatter.WriteEvent(null, writer);
     }
 }
开发者ID:EdHastings,项目名称:semantic-logging,代码行数:8,代码来源:EventTextFormatterTests.cs

示例3: WritesNonEmptyRelatedActivityIdOnSummary

        public void WritesNonEmptyRelatedActivityIdOnSummary()
        {
            var formatter = new EventTextFormatter(verbosityThreshold: EventLevel.Critical);
            using (var writer = new StringWriter())
            {
                var relatedActivityId = Guid.NewGuid();

                formatter.WriteEvent(
                    new EventEntry(
                        Guid.NewGuid(),
                        0,
                        string.Empty,
                        new System.Collections.ObjectModel.ReadOnlyCollection<object>(new object[0]),
                        DateTimeOffset.MaxValue,
                        Guid.Empty,
                        relatedActivityId,
                        new EventSourceSchemaReader().GetSchema(Logger).Values.First()),
                    writer);

                var message = writer.ToString();

                var activityIdMatch = Regex.Match(message, "\\bActivityId : (?<id>[-A-Fa-f0-9]+)\\w?").Groups["id"].Value;
                var relatedActivityIdMatch = Regex.Match(message, "\\bRelatedActivityId : (?<id>[-A-Fa-f0-9]+)\\w?").Groups["id"].Value;

                Assert.AreEqual(string.Empty, activityIdMatch);
                Assert.AreEqual(relatedActivityId.ToString(), relatedActivityIdMatch);
            }
        }
开发者ID:EdHastings,项目名称:semantic-logging,代码行数:28,代码来源:EventTextFormatterTests.cs

示例4: WritesProcessIdAndThreadIdOnSummary

        public void WritesProcessIdAndThreadIdOnSummary()
        {
            var formatter = new EventTextFormatter(verbosityThreshold: EventLevel.Critical);
            using (var writer = new StringWriter())
            {
                var processId = 200;
                var threadId = 300;

                formatter.WriteEvent(
                    new EventEntry(
                        Guid.NewGuid(),
                        0,
                        string.Empty,
                        new System.Collections.ObjectModel.ReadOnlyCollection<object>(new object[0]),
                        DateTimeOffset.MaxValue,
                        processId,
                        threadId,
                        Guid.Empty,
                        Guid.Empty,
                        new EventSourceSchemaReader().GetSchema(Logger).Values.First()),
                    writer);

                var message = writer.ToString();

                var processIdMatch = Regex.Match(message, "\\bProcessId : (?<id>\\d+)\\w?").Groups["id"].Value;
                var threadIdMatch = Regex.Match(message, "\\bThreadId : (?<id>\\d+)\\w?").Groups["id"].Value;

                Assert.AreEqual(processId.ToString(), processIdMatch);
                Assert.AreEqual(threadId.ToString(), threadIdMatch);
            }
        }
开发者ID:EdHastings,项目名称:semantic-logging,代码行数:31,代码来源:EventTextFormatterTests.cs

示例5: InitializeLocalLogging

        protected override void InitializeLocalLogging()
        {
            _platformEventStream = new ObservableEventListener();
            _platformEventStream.EnableEvents(EventSources.PlatformSources, TraceLevel);

            var formatter = new EventTextFormatter(dateTimeFormat: "O");
            _platformEventStream.Subscribe(evt =>
            {
                StringBuilder b = new StringBuilder();
                using (var writer = new StringWriter(b))
                {
                    formatter.WriteEvent(evt, writer);
                }
                Trace.WriteLine(b.ToString());
            });

            try
            {
                var logsResource = RoleEnvironment.GetLocalResource("Logs");

                var logFile = Path.Combine(logsResource.RootPath, "Platform", "Platform.log.json");

                // Initialize core platform logging
                _subscriptions.Add(_platformEventStream.LogToRollingFlatFile(
                    fileName: logFile,
                    rollSizeKB: 1024,
                    timestampPattern: "yyyyMMdd-HHmmss",
                    rollFileExistsBehavior: RollFileExistsBehavior.Increment,
                    rollInterval: RollInterval.Hour,
                    formatter: new JsonEventTextFormatter(EventTextFormatting.Indented, dateTimeFormat: "O"),
                    maxArchivedFiles: 768, // We have a buffer size of 1024MB for this folder
                    isAsync: false));
            }
            catch (Exception ex)
            {
                ServicePlatformEventSource.Log.FatalException(ex);
                throw;
            }
        }
开发者ID:stephenosrajan,项目名称:NuGet.Services.Platform,代码行数:39,代码来源:AzureServiceHost.cs


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