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


C# TraceSource.TraceTransfer方法代码示例

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


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

示例1: 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

示例2: TraceTransferTest

 public void TraceTransferTest()
 {
     var trace = new TraceSource("TestTraceSource", SourceLevels.All);
     var listener = GetTraceListener();
     trace.Listeners.Add(listener);
     trace.TraceTransfer(1, "Trace transfer test message", Trace.CorrelationManager.ActivityId);
     Assert.Equal(1, listener.GetCallCount(Method.TraceTransfer));
     var flushExpected = AutoFlush ? 1 : 0;
     Assert.Equal(flushExpected, listener.GetCallCount(Method.Flush));
 }
开发者ID:dotnet,项目名称:corefx,代码行数:10,代码来源:TraceSourceClassTests.cs


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