static void RunInteractive(string configFilePath) { Log.Logger = new LoggerConfiguration() .WriteTo.Console() .CreateLogger(); try { Log.Information("Running interactively"); var client = new EventLogClient(); client.Start(configFilePath); var done = new ManualResetEvent(false); Console.CancelKeyPress += (s, e) => { Log.Information("Ctrl+C pressed, stopping"); client.Stop(); done.Set(); }; done.WaitOne(); Log.Information("Stopped"); } catch (Exception ex) { Log.Fatal(ex, "An unhandled exception occurred"); Environment.ExitCode = 1; } finally { Log.CloseAndFlush(); } }
protected override void OnStart(string[] args) { _client.Start(); }