本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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");
}
示例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();
}
示例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();
}
示例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();
}