log4net.Appender.RabbitMQAppender.Process C# (CSharp) 메소드

Process() 공개 메소드

public Process ( log4net.Core.LoggingEvent logs ) : void
logs log4net.Core.LoggingEvent
리턴 void
        public void Process(LoggingEvent[] logs)
        {
            Stopwatch sw = Stopwatch.StartNew();
            try
            {
                LogLog.Debug(typeof(RabbitMQAppender), string.Concat("publishing ", logs.Length, " logs"));
                byte[] body = _messageBuilder.Build(logs);
                using (IConnection connection = _connectionFactory.CreateConnection())
                {
                    using (IModel model = connection.CreateModel())
                    {
                        IBasicProperties basicProperties = model.CreateBasicProperties();
                        basicProperties.ContentEncoding = _messageBuilder.ContentEncoding;
                        basicProperties.ContentType = _messageBuilder.ContentType;
                        basicProperties.DeliveryMode = 2;
                        model.BasicPublish(Exchange, RoutingKey, basicProperties, body);
                    }
                }
            }
            catch (Exception e)
            {
                LogLog.Debug(typeof(RabbitMQAppender), "Exception comunicating with rabbitmq", e);
            }
            finally
            {
                LogLog.Debug(typeof(RabbitMQAppender), string.Concat("process completed, took ", sw.Elapsed));
            }
        }