コード例 #1
0
        private const int RefreshRate = 1000;  // 1sec

        static void Main(string[] args)
        {
            ILogReceiver receiver = new RabbitMQReceiver();

            receiver.Init();
            foreach (var severity in LogSeverity.Values())
            {
                receiver.BindRoute(severity);
            }
            receiver.Listen((severity, message) => {
                LogAnalysis[severity]++;
            });
            new Task(WriteLogStats).Start();

            Console.ReadKey();
            receiver.Close();
        }
コード例 #2
0
 static void Main(string[] args)
 {
     using (var w = File.AppendText("application.log"))
     {
         ILogReceiver receiver = new RabbitMQReceiver();
         receiver.Init();
         var severities = new[] { LogSeverity.Warning, LogSeverity.Error, LogSeverity.Critical };
         foreach (var severity in severities)
         {
             receiver.BindRoute(severity);
         }
         receiver.Listen((severity, message) => {
             w.WriteLine($"[{DateTime.Now:dd-MM-yyyy H:mm:ss}][{severity.Value.ToUpper()}]: {message}");
         });
         Console.WriteLine("Press any key to exit.");
         Console.ReadKey();
         receiver.Close();
     }
 }