示例#1
0
 public void Send(GelfMessage message)
 {
     using (var udpClient = new UdpClient())
         foreach (var bytes in encoder.Encode(messageSerializer.Serialize(message)))
         {
             var result = udpClient.SendAsync(bytes, bytes.Length, configuration.Host).Result;
         }
 }
示例#2
0
 public void Send(GelfMessage message)
 {
     using (var udpClient = new UdpClient())
         foreach (var bytes in encoder.Encode(messageSerializer.Serialize(message)))
         {
             udpClient.Send(bytes, bytes.Length, configuration.GetHost());
         }
 }
示例#3
0
 public void Send(GelfMessage message)
 {
     EstablishConnection();
     using (var stream = client.GetStream())
     {
         var bytes = messageSerializer.Serialize(message);
         stream.Write(bytes, 0, bytes.Length);
         stream.WriteByte(0);
     }
 }
示例#4
0
        public void Send(GelfMessage message)
        {
            EstablishConnection();
            var serialzed = messageSerializer.Serialize(message);
            var encoded   = encoder.Encode(serialzed);

            foreach (var bytes in encoded)
            {
                udpClient.Send(bytes, bytes.Length);
            }
        }
示例#5
0
 public void Send(GelfMessage message)
 {
     EstablishConnection();
     foreach (var bytes in encoder.Encode(messageSerializer.Serialize(message)))
     {
         var basicProperties = new BasicProperties
         {
             DeliveryMode = configuration.Persistent ? (byte)2 : (byte)1
         };
         channel.BasicPublish(configuration.Exchange, configuration.RoutingKey, false, false, basicProperties, bytes);
     }
 }
示例#6
0
        public void Send(GelfMessage message)
        {
            EstablishConnection();

            var bytes = messageSerializer.Serialize(message);

            try
            {
                connection.Stream.Write(bytes, 0, bytes.Length);
                connection.Stream.WriteByte(0);
            }
            catch (Exception)
            {
                Close();

                throw;
            }
        }
示例#7
0
        public void Send(GelfMessage message)
        {
            var request = (HttpWebRequest)WebRequest.Create(configuration.Uri);

            using (var requestStream = request.GetRequestStream())
                using (var messageStream = new MemoryStream(messageSerializer.Serialize(message)))
                    messageStream.CopyTo(requestStream);
            request.Method            = "POST";
            request.AllowAutoRedirect = false;
            request.ReadWriteTimeout  = request.Timeout = configuration.Timeout;
            using (var response = (HttpWebResponse)request.GetResponse())
            {
                if (response.StatusCode == HttpStatusCode.Accepted)
                {
                    return;
                }
                throw new SendFailedException();
            }
        }