how to write to kiwi syslog server log c#

11,213

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());
Share:
11,213
Alon M
Author by

Alon M

Updated on July 19, 2022

Comments

  • Alon M
    Alon M almost 2 years

    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!

  • Alon M
    Alon M over 10 years
    Which code did you put into your code, i mean which dll and if you odnt mind puting "this is the meesage" into the meesage place
  • i3arnon
    i3arnon over 10 years
    I added a nuget. Do you know how to do that. Visual studio automatically downloads and adds everything you need.
  • Alon M
    Alon M over 10 years
    Visual stuido should add me automatically if added this code to my code? how?
  • i3arnon
    i3arnon over 10 years
    You need to install the nugget. In the link I added there are explanations on how to add a nugget. You can do that with a right click on your project and manage nugget extensions. One you find the nugget and install it then you can use this code.
  • Alon M
    Alon M over 10 years
    i am looking for nuget in the vs but cant find this one, how can i do that? i have added syslog.net from nuget, what now?
  • i3arnon
    i3arnon over 10 years
    If you added it.. Just write the code like I showed. Create a serializer, a sender, a message and send it.
  • i3arnon
    i3arnon over 10 years
    You can't just copy my code.. You need to write it according to your needs. If you have troubles with your code you need a new question and show your code so everybody can help you.
  • i3arnon
    i3arnon over 10 years
    And I gave you one. Which I guarantee works. If you have difficulties using the library you need to specify code and errors in a new question. People won't read the comments to help you...
  • Alon M
    Alon M over 10 years
    Ok i will, 1. Error 4 Cannot implicitly convert type 'SyslogNet.Client.Serialization.SyslogRfc3164MessageSerializ‌​er' to 'SyslogNet.Client.Transport.SyslogUdpSender' C:\code\Custome‌​rs\FIBI\PWFileUpload‌​er\PWFileUploaderApp‌​lication\UploadForm.‌​cs 90 29 PWFileUploa‌​derApplication 2. the name notification does not exist in the cuurent contex. and more
  • i3arnon
    i3arnon over 10 years
    @AlonM I updated the code.. It should remove most of your errors.
  • Garry
    Garry almost 7 years
    @i3arnon I made a small console application in C# and installed the Install-Package SyslogNet.Client and ran your snippet ... but nothing appears in my Visual Syslog server...