C# .NET UDP 形式调用 graylog,gelf

2021-05-23 06:28

阅读:457

标签:json   type   col   color   ring   graylog   span   pad   mil   

 

 

--

发送:

GelfLogModel m = new GelfLogModel();
                m.version = "1.1";
                m.host = "128.0.14.39";
                m.short_message = "异常"; //三个必须
                m.full_message = "full_message ,测试1";
                m.timestamp = MU.GetTimeStampTen();

                string json = JsonConvert.SerializeObject(m);

                

                IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("128.0.255.10"), 12201);
                Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

                byte[] data = Encoding.UTF8.GetBytes(json);
                server.SendTo(data, data.Length, SocketFlags.None, ipep);//将数据发送到指定的终结点

                MessageBox.Show("finish");

 

 

 

---

timestamp:

public static long GetTimeStampTen()
        {
            return (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
        }

 

 

---

C# .NET UDP 形式调用 graylog,gelf

标签:json   type   col   color   ring   graylog   span   pad   mil   

原文地址:https://www.cnblogs.com/runliuv/p/11145864.html


评论


亲,登录后才可以留言!