Syslog library for .NET Framework

This is a Syslog beta version of the forthcoming Rebex Syslog library. It contains both server and client part. Both can communicate over UDP or TCP.

And it's available for free!

Download Rebex Syslog .NET »

Syslog server C# sample (consumer)

using Rebex.Net;

...

// create Syslog server object
SyslogServer server = new SyslogServer(Syslog.DefaultPort);

// register MessageReceived event
server.MessageReceived += SyslogMessageReceived;

// start the server
server.Start();

...

// MessageReceived event handler
static void SyslogMessageReceived(object sender, MessageReceivedEventArgs args)
{
	SyslogMessage m = args.Message;

	// display received message
	Console.WriteLine("Syslog: [{0}] <{1}> {2}", m.Facility, m.Severity, m.Text);
}

Notes for heavy load scenario

There are basically two possibilities how the receiver process can work:

  1. Simple solution: wait for data, process data, start receiving data again.
  2. Advanced solution: wait for data, put data to processing queue, start receiving data again immediately, process received data on backgroud.
In this beta version we choose to implement simple solution.

The received data are reported using the MessageReceived event and you should keep in mind two things:

  1. Underlying receiver socket is blocked until the MessageReceived event handler is finished.
  2. In case of multiple connected TCP clients (or using both UDP and TCP clients), the MessageReceived event handler can be raised concurrently (received data from two clients can be processed at the same time).

Suggestion: you can handle both limitations by using appropriate producer-consumer model. For example from .NET 4.0 the System.Collections.Concurrent.BlockingCollection can be used to handle this.

Still, when using only one client, or only UDP clients, you don't need to worry about concurrent calls (you can disable TCP by setting SyslogServer.TcpEnabled to false).

Syslog client C# sample (sender)

using Rebex.Net;

...

// create Syslog client object
Syslog client = new Syslog(TransportProtocol.Udp, "localhost", Syslog.DefaultPort);

// initialize Syslog message
SyslogMessage msg = new SyslogMessage();
msg.Facility = FacilityLevel.User;
msg.Severity = SeverityLevel.Debug;
msg.Text = "Hello from Syslog client.";

// send message(s)
client.Send(msg);

// close the client
client.Close();

Standards

Change log

2016-12-12 - 1.1 
           - Server can listen on specific IP address.
           - RemoteEndPoint and Received properties added for incomming SyslogMessage.
           - TextEncoding support added for outgoing SyslogMessage.
           - Added sample application
2016-06-27 - 1.0 
           - First version released.

Send us feedback

Do you have any questions, would you like to discuss anything or do you have any kind of feedback?

Contact us at support@rebex.net or forum.rebex.net.