Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SyslogEventSink.cs
1using System;
2using System.Security.Cryptography.X509Certificates;
3using System.Threading.Tasks;
5
7{
12 {
13 private SyslogClient client;
14
25 public SyslogEventSink(string Host, int Port, bool Tls, string LocalHostName,
26 string AppName, SyslogEventSeparation Separation, string ObjectID)
27 : base(ObjectID)
28 {
29 this.client = new SyslogClient(Host, Port, Tls, LocalHostName, AppName, Separation);
30 }
31
42 public SyslogEventSink(string Host, int Port, X509Certificate Certificate,
43 string LocalHostName, string AppName, SyslogEventSeparation Separation,
44 string ObjectID)
45 : base(ObjectID)
46 {
47 this.client = new SyslogClient(Host, Port, Certificate, LocalHostName, AppName, Separation);
48 }
49
54 public override async Task Queue(Event Event)
55 {
56 try
57 {
58 await this.client.Send(Event);
59 }
60 catch (Exception ex)
61 {
62 Event Event2 = new Event(EventType.Critical, ex, this.ObjectID,
63 string.Empty, string.Empty, EventLevel.Medium, string.Empty,
64 string.Empty);
65 Event2.Avoid(this);
66
67 Log.Event(Event2);
68 }
69 }
70
74 public override async Task DisposeAsync()
75 {
76 if (!(this.client is null))
77 {
78 await this.client.DisposeAsync();
79 this.client = null;
80 }
81
82 await base.DisposeAsync();
83 }
84
89 public void UpdateCertificate(X509Certificate Certificate)
90 {
91 this.client.UpdateCertificate(Certificate);
92 }
93 }
94}
Class representing an event.
Definition: Event.cs:11
void Avoid(IEventSink EventSink)
If the event sink EventSink should be avoided when logging the event.
Definition: Event.cs:190
Base class for event sinks.
Definition: EventSink.cs:9
Static class managing the application event log. Applications and services log events on this static ...
Definition: Log.cs:14
static async void Event(Event Event)
Logs an event. It will be distributed to registered event sinks.
Definition: Log.cs:138
virtual string ObjectID
Object ID, used when logging events.
Definition: LogObject.cs:26
Syslog over TCP/IP client application, as defined in RFCs 5224, 5425, 6587: https://datatracker....
Definition: SyslogClient.cs:25
Task Send(Event Event)
Sends an event to the syslog server.
void UpdateCertificate(X509Certificate Certificate)
Updates the certificate used in mTLS negotiation.
async Task DisposeAsync()
Disposes the syslog client.
Event sink that sends events to a Syslog server using the Syslog protocol.
SyslogEventSink(string Host, int Port, bool Tls, string LocalHostName, string AppName, SyslogEventSeparation Separation, string ObjectID)
Event sink that sends events to a Syslog server using the Syslog protocol.
override async Task DisposeAsync()
IDisposableAsync.DisposeAsync()
SyslogEventSink(string Host, int Port, X509Certificate Certificate, string LocalHostName, string AppName, SyslogEventSeparation Separation, string ObjectID)
Event sink that sends events to a Syslog server using the Syslog protocol.
override async Task Queue(Event Event)
Queues an event to be output.
void UpdateCertificate(X509Certificate Certificate)
Updates the certificate used in mTLS negotiation.
Interface for Mutual TLS (mTLS) Clients or TLS servers.
SyslogEventSeparation
How events are separated in the Syslog event stream.
EventLevel
Event level.
Definition: EventLevel.cs:7
EventType
Type of event.
Definition: EventType.cs:7