SyslogClient Class
Namespace: Rebex.Net
Assembly: Rebex.Syslog.dll (version 8.0.9673)
Represents a syslog client, which can send syslog messages to a syslog server.
See https://www.rebex.net/syslog/features/ for code snippets of common use cases.
Syntax
public class SyslogClient : IDisposable, IAsyncDisposable
Inherited Members
Examples
See https://www.rebex.net/syslog/samples.aspx for ready-to-use samples.
// initialize new Syslog client instance
var client = new Rebex.Net.SyslogClient();
// attach logger for diagnostic purposes
client.LogWriter = new Rebex.FileLogWriter(@"C:\MyData\syslog.log");
// connect to desired Syslog server
client.Connect(hostname, SyslogTransportProtocol.Tcp);
// prepare Syslog message
var message = new SyslogMessage();
message.Facility = SyslogFacility.User;
message.Severity = SyslogSeverity.Informational;
// send some messages
foreach (var text in new[] { "Hello!", "This is a test.", "DONE" })
{
message.Text = text;
client.Send(message);
}
Constructors
| Name | Description |
|---|---|
| SyslogClient() | Initializes an instance of the SyslogClient class and bind it to the specified syslog server. 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 |
|---|---|
| LogWriter | Gets or sets the LogWriter used by this object. |
| Settings | Gets or sets the client settings. |
| Timeout | Gets or sets the timeout for underlying socket. |
Methods
| Name | Description |
|---|---|
| Close() | Closes the connection and releases all associated resources. |
| CloseAsync() | Asynchronously closes the connection and releases all associated resources. |
| Connect(String, SyslogTransportProtocol) | Connects the client to the specified syslog server. |
| Connect(String, Int32, SyslogTransportProtocol) | Connects the client to the specified syslog server. |
| ConnectAsync(String, Int32, SyslogTransportProtocol) | Connects the client to the specified syslog server. |
| Send(SyslogMessage) | Sends a message to the connected syslog server. |
| Send(String, SyslogSeverity, SyslogFacility) | Sends a message to the connected syslog server. |
| SendAsync(SyslogMessage) | Sends a message to the connected syslog server. |
| SendAsync(String, SyslogSeverity, SyslogFacility) | Sends a message to the connected syslog server. |
Events
| Name | Description |
|---|---|
| ValidatingCertificate | Occurs when a certificate provided by the remote end needs to be validated. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IAsyncDisposable.DisposeAsync() | Asynchronously closes the connection and releases all associated resources. |
| IDisposable.Dispose() | Disposes the object. |