how to write to kiwi syslog server log c#

Alon M picture Alon M · Jan 6, 2014 · Viewed 10.2k times · Source

I have a program that I need to send some logs into Kiwi Syslog Server. I have looked around the net for a guide in c#, but I found nothing. I would like to have an easy to understand explanation of how to do it.

Whenever someone clicks on a button or does something important, I just want to be able to write a log entry for it. So, really all I need is an example on how you send entries to the Syslog Server.

I don't have any example code of what I already did because I found nothing that I can show off. I hope that i don't break the rules of this site by not showing any code already. But believe me, I tried to look around the net for it.

Thanks a lot for your help guys!

Answer

i3arnon picture i3arnon · Jan 6, 2014

There's an awesome open-source SysLog Library for .Net: SyslogNet.

Here's an example where I create a sender, create a message and send it:

_syslogSender = new SyslogUdpSender("localhost",514);
_syslogSender.Send(
    new SyslogMessage(
        DateTime.Now,
        Facility.SecurityOrAuthorizationMessages1,
        Severity.Informational,
        Environment.MachineName,
        "Application Name",
        "Message Content"),
    new SyslogRfc3164MessageSerializer());