/// <summary> /// Study EventListener class. /// https://msdn.microsoft.com/zh-cn/library/system.diagnostics.tracing.eventlistener(v=vs.110).aspx /// </summary> public static void TestDiagnostic05() { EventListener verboseListener = new ConsoleEventListener(); verboseListener.EnableEvents(MyCompanyEventSource01.Log, EventLevel.Verbose); TestDiagnostic03(); verboseListener.Dispose(); }
public static void Main() { using (var eventListener = new ConsoleEventListener()) { var eventSource = new HelloEventSource(); eventListener.EnableEvents(eventSource, EventLevel.Verbose); eventSource.Hello("Hello World!"); } }
private static void InitializeTracing(string testName) { string log = Path.Combine(Environment.GetEnvironmentVariable("_NTTREE"), "FabricUnitTests", "log"); Utility.TraceSource = Trace.GetEventSource(FabricEvents.Tasks.FabricDeployer); validatorConsoleTraces.EnableEvents(FabricEvents.Events, EventLevel.Informational); string fileName = Path.Combine(log, testName); Utility.InitializeTraceSource(fileName); Utility.TraceSource.WriteInfo("Test", "Starting test {0}", testName); }