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


C# TraceSource.Flush方法代码示例

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


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

示例1: TestTraceSourceLogging

        public void TestTraceSourceLogging()
        {
            TraceSource source = new TraceSource("TestOfIoCXmlRollingWriter");

            for (int i = 0; i < 100000; i++)
            {
                source.TraceData(TraceEventType.Information, i, "test of test data");
                source.Flush();
            }
            source.Flush();
        }
开发者ID:alienwaredream,项目名称:toolsdotnet,代码行数:11,代码来源:XmlWriterRollingTraceSourceTest.cs

示例2: LogMessagesTo

 private static void LogMessagesTo(TraceSource traceSource)
 {
     var log = new Log(traceSource);
     log.Verbose(_verboseMessage);
     log.Information(_infoMessage);
     log.Warning(_warningMessage);
     log.Error(_errorMessage);
     traceSource.Flush();
 }
开发者ID:Lsuwito,项目名称:SampleApp,代码行数:9,代码来源:LogTest.cs

示例3: Main

        public static void Main(string[] args)
        {
            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);

            traceSource.TraceInformation("Tracing application...");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1, new object[] { "a", "b", "c" });

            traceSource.Flush();
            traceSource.Close();
        }
开发者ID:nissbran,项目名称:Training-Certifications,代码行数:11,代码来源:Program.cs

示例4: HowToUseTheTraceSourceClass

        public static void HowToUseTheTraceSourceClass()
        {
            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);

            traceSource.TraceInformation("Tracing app");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1, new object[] { "a", "b", "c" });

            traceSource.Flush();
            traceSource.Close();
        }
开发者ID:Chaek,项目名称:MCSD,代码行数:11,代码来源:TraceSourceExample.cs

示例5: DoTrace

 public static void DoTrace()
 {
     Stream outputFile = File.Create("tracefile.txt");
     TextWriterTraceListener textListener =
     new TextWriterTraceListener(outputFile);
     TraceSource traceSource = new TraceSource("myTraceSource",
     SourceLevels.All);
     traceSource.Listeners.Clear();
     traceSource.Listeners.Add(textListener);
     traceSource.TraceInformation("Trace output");
     traceSource.Flush();
     traceSource.Close();
 }
开发者ID:ErhanGDC,项目名称:MyWorks,代码行数:13,代码来源:Program.cs

示例6: Main

        static void Main(string[] args)
        {
            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);

            traceSource.TraceInformation("Tracing application.");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1, new object[] { "a", "b", "c" });

            traceSource.Flush();
            traceSource.Close();

            Console.WriteLine("Press a key to exit");
            Console.ReadKey();
        }
开发者ID:jbijoux,项目名称:Exam70_483,代码行数:14,代码来源:Program.cs

示例7: HowToUseTheTraceListenerClass

        public static void HowToUseTheTraceListenerClass()
        {
            Stream outputFile = File.Create("traceFile.txt");
            TextWriterTraceListener textListener = new TextWriterTraceListener(outputFile);

            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);

            traceSource.Listeners.Clear();
            traceSource.Listeners.Add(textListener);

            traceSource.TraceInformation("Tracing app");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1, new object[] { "a", "b", "c" });

            traceSource.Flush();
            traceSource.Close();
        }
开发者ID:Chaek,项目名称:MCSD,代码行数:17,代码来源:TraceSourceListenerExample.cs

示例8: FileHandlesEventFromTraceSource

        public void FileHandlesEventFromTraceSource()
        {
            var mockFileSystem = new MockFileSystem();
            TraceSource source = new TraceSource("rollingFile1Source");
            var listener = source.Listeners.OfType<RollingFileTraceListener>().First();
            listener.FileSystem = mockFileSystem;

            source.TraceEvent(TraceEventType.Warning, 2, "{0}-{1}", 3, "B");
            source.Flush(); // or have AutoFlush configured

            Assert.AreEqual(1, mockFileSystem.OpenedItems.Count);
            var tuple0 = mockFileSystem.OpenedItems[0];
            // (earlier name was "QTAgent32-")
            // VS2012 process name "vstest.executionengine.x86-"
            // VS2015 process name "te.processhost.managed-"
            //StringAssert.StartsWith(tuple0.Item1, "vstest.executionengine.x86-" + DateTimeOffset.Now.Year.ToString());
            var output = Encoding.UTF8.GetString(tuple0.Item2.GetBuffer(), 0, (int)tuple0.Item2.Length);
            StringAssert.Contains(output, "Warning rollingFile1Source 2: 3-B");
        }
开发者ID:amccool,项目名称:essentialdiagnostics,代码行数:19,代码来源:RollingFileTests.cs

示例9: Main

        static void Main(string[] args)
        {
            Debug.WriteLine("Starting application");
            Debug.Indent();
            int i = 1 + 2;
            Debug.Assert(i == 3);
            Debug.WriteLineIf(i > 0, "i is greater than 0");

            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);
            traceSource.TraceInformation("Tracing application..");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1,
            new object[] { "a", "b", "c" });
            traceSource.Flush();
            traceSource.Close();

            DoTrace();

            Console.ReadLine();
        }
开发者ID:ErhanGDC,项目名称:MyWorks,代码行数:20,代码来源:Program.cs

示例10: Write

 /// <summary>
 /// Writes to the specified Trace source.
 /// </summary>
 /// <param name="source">The trace source.</param>
 /// <param name="level">The message level.</param>
 /// <param name="message">The message.</param>
 private static void Write(string source, TraceEventType level, string message) {
   TraceSource messageTrace = new TraceSource(source);
   messageTrace.TraceEvent(level, ADS_API_TRACE_ID, message);
   messageTrace.Flush();
 }
开发者ID:Zweitze,项目名称:googleads-adwords-dotnet-lib,代码行数:11,代码来源:TraceUtilities.cs

示例11: LogExceptionInternal

		private static void LogExceptionInternal(string message, TraceEventType severity)
		{
			var traceSource = new TraceSource(Assembly.GetEntryAssembly().GetName().Name);
			traceSource.TraceEvent(severity, 0, message);
			traceSource.Flush();
			traceSource.Close();
		}
开发者ID:Philo,项目名称:Revalee,代码行数:7,代码来源:Supervisor.cs


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