SyslogServer Class
Namespace: Rebex.Net
Assembly: Rebex.Syslog.dll (version 8.0.9673)
Represents a syslog server that can receive syslog messages.
See https://www.rebex.net/syslog/features/ for code snippets of common use cases.
Syntax
public class SyslogServer : IDisposable
Implements
Inherited Members
Examples
See https://www.rebex.net/syslog/samples.aspx for ready-to-use samples.
Starting the Syslog server
// initialize new Syslog server instance
var server = new SyslogServer();
// attach logger for diagnostic purposes
server.LogWriter = new Rebex.FileLogWriter(@"C:\MyData\syslog.log", LogLevel.Debug);
// bind endpoints
server.Bind(SyslogServer.DefaultPort, SyslogTransportProtocol.Udp);
server.Bind(SyslogServer.DefaultPort, SyslogTransportProtocol.Tcp);
// register an event handler for received messages
server.MessageReceived += (s, e) =>
{
Console.WriteLine("Message from {0}: {1}", e.RemoteEndPoint, e.Message.Text);
};
// register an event handler for errors
server.ErrorOccurred += (s, e) =>
{
Console.WriteLine("Error occurred ({0}): {1}", e.RemoteEndPoint, e.Error);
};
// start server in the background
server.Start();
See Processing received messages article to learn about MessageReceived event limitations and how to utilize System.Collections.Concurrent.BlockingCollection to overcome them.
Constructors
| Name | Description |
|---|---|
| SyslogServer() | Initializes an instance of the SyslogServer class. Use one of the Bind methods to bind the server to an endpoint. See https://www.rebex.net/syslog/features/ for code snippets of common use cases. |
Fields
| Name | Description |
|---|---|
| DefaultPort | Default syslog port number (514). |
| DefaultTlsPort | Default syslog port number for TLS connection (6514). |
Properties
| Name | Description |
|---|---|
| Bindings | Gets a read-only collection of server bindings. |
| LogWriter | Gets or sets the LogWriter used by this object. |
| Settings | Gets or sets the server settings. |
Methods
| Name | Description |
|---|---|
| Bind(SyslogBinding) | Binds the server to an endpoint using specified settings. |
| Bind(SyslogTransportProtocol) | Binds the specified protocol listener to its default port on all network IPv4 interfaces. |
| Bind(IEnumerable<SyslogBinding>) | Binds the server to the endpoints using specified settings. |
| Bind(Int32, SyslogTransportProtocol) | Binds the server to the specified port on all network IPv4 interfaces. |
| Bind(IPEndPoint, SyslogTransportProtocol) | Binds the server to the specified endpoint. |
| Dispose() | Disposes the server object, releasing all listeners and sessions. |
| Start() | Starts the server. |
| Stop() | Stops the server. |
| Unbind() | Unbinds server from all network interfaces. |
| Unbind(SyslogBinding) | Unbinds server from the specified endpoint, which uses specified protocol. |
| Unbind(SyslogTransportProtocol) | Unbinds server from endpoints used by the specified protocol. |
| Unbind(Int32) | Unbinds server from endpoints listening on specified port. |
| Unbind(IPAddress) | Unbinds server from endpoints listening on specified address. |
| Unbind(IPEndPoint) | Unbinds server from the specified endpoint. |
Events
| Name | Description |
|---|---|
| ErrorOccurred | Occurs when an error occurs while receiving syslog messages. |
| MessageReceived | Occurs when a syslog message is received. |