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


C# TraceSource.TraceData方法代码示例

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


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

示例1: DoItTraceListener

 static async void DoItTraceListener()
 {
     var source = new TraceSource("Test");
     source.Switch.Level = SourceLevels.All;
     var listener = new HttpEventCollectorTraceListener(new Uri("https://localhost:8088"), "3E712E99-63C5-4C5A-841D-592DD070DA51");
     listener.AddLoggingFailureHandler(e => Console.WriteLine(e.Message));
     source.Listeners.Add(listener);
     source.TraceData(TraceEventType.Information, 1, new { Foo = "Bar" });
     dynamic obj = new JObject();
     obj.Bar = "Baz";
     source.TraceData(TraceEventType.Information, 1, (JObject)obj);
     await listener.FlushAsync();
 }
开发者ID:glennblock,项目名称:SendJsonToHec,代码行数:13,代码来源:Program.cs

示例2: CauseFailedSerialization

        public void CauseFailedSerialization()
        {
            var x = new ElasticSearchTraceListener("tester");
            x.ElasticSearchUri = "http://192.168.2.50:9200";
            x.ElasticSearchTraceIndex = "trace";

            var ts = new TraceSource("exxxxx", SourceLevels.All);
            ts.Listeners.Add(x);

            for (int i = 0; i < 50; i++)
            {

            ts.TraceData(TraceEventType.Information, 99, new Junk()
            {
                ipaddr = IPAddress.Parse("1.1.1.1")
            });
            }

            ts.Flush();
        }
开发者ID:amccool,项目名称:ElasticSearch.Diagnostics,代码行数:20,代码来源:ESTLUnitTests.cs

示例3: TraceDataWithString

        public void TraceDataWithString()
        {
            var x = new ElasticSearchTraceListener("tester");
            x.ElasticSearchUri = "http://192.168.2.50:9200";
            x.ElasticSearchTraceIndex = "trace";

            var ts = new TraceSource("exxxxx", SourceLevels.All);
            ts.Listeners.Add(x);

            ts.TraceData(TraceEventType.Error, 99, "ggggggggggggggggg");

            x.Flush();
        }
开发者ID:amccool,项目名称:ElasticSearch.Diagnostics,代码行数:13,代码来源:ESTLUnitTests.cs

示例4: TSManyWriteExceptionsTest

        public void TSManyWriteExceptionsTest()
        {
            var x = new ElasticSearchTraceListener("tester");
            x.ElasticSearchUri = "http://192.168.2.50:9200";
            x.ElasticSearchTraceIndex = "trace";

            var ts = new TraceSource("exxxxx", SourceLevels.All);
            ts.Listeners.Add(x);

            try
            {
                var n = 0;
                var y = 100000 / n;
            }
            catch (Exception ex)
            {
                for (int i = 0; i < 10000; i++)
                {
                    ts.TraceData(TraceEventType.Error, 99, ex);
                }
            }
            x.Flush();
        }
开发者ID:amccool,项目名称:ElasticSearch.Diagnostics,代码行数:23,代码来源:ESTLUnitTests.cs

示例5: TraceData2Test

 public void TraceData2Test()
 {
     var trace = new TraceSource("TestTraceSource", SourceLevels.All);
     var listener = GetTraceListener();
     trace.Listeners.Add(listener);
     trace.TraceData(TraceEventType.Verbose, 0, new Object[0]);
     Assert.Equal(1, listener.GetCallCount(Method.TraceData));
     var flushExpected = AutoFlush ? 1 : 0;
     Assert.Equal(flushExpected, listener.GetCallCount(Method.Flush));
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:10,代码来源:TraceSourceClassTests.cs

示例6: ShouldLogWithXmlRollingListenerNoConfig

        public void ShouldLogWithXmlRollingListenerNoConfig()
        {
            // Setup source and listener
            string initializationString =
                @"name = XmlLogger; logrootpath = c:\logs; staticpattern = log_; maxSizeBytes = 20000;";

            XmlWriterRollingTraceListener traceListener =
                new XmlWriterRollingTraceListener(initializationString);

            TraceSource log = new TraceSource("Test", SourceLevels.All);

            log.Listeners.Clear();
            log.Listeners.Add(traceListener);

            // Start Activity #1
            Guid activity1Guid = Guid.NewGuid();

            Trace.CorrelationManager.ActivityId = activity1Guid;

            log.TraceEvent(TraceEventType.Start, 2, "Activity #1");

            // log information inside Activity #1
            log.TraceInformation("Information from Activity #1");

            // Start Activity #2
            Guid activity2Guid = Guid.NewGuid();

            log.TraceTransfer(3, "Transferring to Activity #2", activity2Guid);

            Trace.CorrelationManager.ActivityId = activity2Guid;

            log.TraceData(TraceEventType.Start, 4, "Activity #2");

            // Complete Activity #2
            log.TraceEvent(TraceEventType.Stop, 5, "Completing Activity #2");

            log.TraceTransfer(6, "Returning back to Activity #1", activity1Guid);

            // Get back into Activity #1
            Trace.CorrelationManager.ActivityId = activity1Guid;
            // Log something extra in Activity #1 before completing it
            log.TraceEvent(TraceEventType.Warning, 7, "Warning from Activity #1");
            // Complete Activity #1
            log.TraceEvent(TraceEventType.Stop, 8, "Completing Activity #1");
        }
开发者ID:alienwaredream,项目名称:toolsdotnet,代码行数:45,代码来源:LoggingTest.cs

示例7: GenerateData

 private static int GenerateData(TraceSource trace, int eventsPerLoop = 50)
 {
     int eventCounter = 0, id = 0;
     foreach (TraceEventType eventType in new TraceEventType[] { TraceEventType.Error, TraceEventType.Information, TraceEventType.Warning })
     {
         for (int i = 0; i < eventsPerLoop; i++, id++, eventCounter++)
         {
             trace.TraceData(eventType, id, new string[] { "TraceData", eventType.ToString(), string.Format("This is event {0}", id) });
         }
     }
     foreach (TraceEventType eventType in new TraceEventType[] { TraceEventType.Error, TraceEventType.Information, TraceEventType.Warning })
     {
         for (int i = 0; i < eventsPerLoop; i++, id++, eventCounter++)
         {
             trace.TraceEvent(eventType, id, "TraceEvent " + eventType.ToString() + string.Format(" This is event {0}", id));
         }
     }
     for (int i = 0; i < eventsPerLoop; i++, id++, eventCounter++)
     {
         trace.TraceInformation(string.Format("TraceInformation. This is event {0}", id));
     }
     return eventCounter;
 }
开发者ID:JimSimpkins13,项目名称:splunk-library-dotnetlogging,代码行数:23,代码来源:TestWithSplunk.cs


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