예제 #1
0
        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();
            }
        }
예제 #2
0
 protected override void OnStart(string[] args)
 {
     _client.Start();
 }