private void DisposeEventTracing() { if (_dbListener != null) { _dbListener.DisableEvents(BlueprintEventSource.Log); _dbListener.DisableEvents(CLogEventSource.Log); _dbListener.DisableEvents(StandardLogEventSource.Log); _dbListener.DisableEvents(PerformanceLogEventSource.Log); _dbListener.DisableEvents(SQLTraceLogEventSource.Log); _dbListener.Dispose(); } }
void RefreshDiagnosticSource() { var diagSource = EventSource.GetSources().FirstOrDefault(x => x.Name == "Microsoft-Diagnostics-DiagnosticSource"); if (diagSource == null) { return; } listener.DisableEvents(diagSource); if (enabledSources.Count > 0) { listener.EnableEvents(diagSource, EventLevel.Informational, EventKeywords.All, new Dictionary <string, string> { { "FilterAndPayloadSpecs", string.Join(Environment.NewLine, enabledSources) } }); } }
private void DoCommand(EventSource source, EventCommand command, FilteringOptions options) { if (command == EventCommand.Enable) { _listener.EnableEvents(source, options.Level, options.Keywords, options.Args); } else if (command == EventCommand.Disable) { _listener.DisableEvents(source); } else { throw new NotImplementedException(); } }
static void SimpleEventSourceAlternativeApproach() { // Set up and enable the event listener - typically done when the application starts EventListener listener = ConsoleLog.CreateListener(); listener.EnableEvents(MyCompanyEventSource.Log, EventLevel.LogAlways, Keywords.All); // Log some messages MyCompanyEventSource.Log.Startup(); MyCompanyEventSource.Log.Failure("Couldn't connect to server."); Console.WriteLine("Written two log messages.\nUsing a basic console listener to capture them."); Console.WriteLine("The color is determined by the severity level.\n"); // Disable and dispose the event listener - typically done when the application terminates listener.DisableEvents(MyCompanyEventSource.Log); listener.Dispose(); }