Add logging using a SLAB sink

The following snippet demonstrates creating an ObservableEventListener object, and then subscribing to events with a UdpEventSink object configured to communicate with localhost on port 10000. Then a SimpleEventSource object is instantiated and a test event is generated and sent via UDP (or TCP) to Splunk Enterprise.

The following code should go inside of a method:

// setup
var listener = new ObservableEventListener();
listener.Subscribe(new UdpEventSink(IPAddress.Loopback, 10000));

var eventSource = new SimpleEventSource();
listener.EnableEvents(eventSource, EventLevel.LogAlways, Keywords.All);

// log an event
eventSource.Message("Test event");

The following code should go elsewhere, outside the method that contains the preceding code:

[EventSource(Name = "TestEventSource")]
public class SimpleEventSource : EventSource
{
    public class Keywords { }
    public class Tasks { }

    [Event(1, Message = "{0}", Level = EventLevel.Error)]
    internal void Message(string message)
    {
        this.WriteEvent(1, message);
    }
}