Skip to content
dcampillo edited this page Dec 27, 2013 · 1 revision

A simple sample to generate a "one field" log for Splunk

 EventFactory _e = new EventFactory("LogGeneratorSample", true);
 
 // Setup event factory with one fields to contain a message
 _e.Fields.Add(new EventFieldDefinition("message", false));
 
 // Get a new event from the EventFactory
 Event _ev = _e.NewEvent();
 
 // Fill the newly created event
 _ev["message"].Value = "Hello World Sample";
 
 // Flush log to the console
 Console.WriteLine(_e.Flush());

Console Output

 2013-12-27T14:41:47.1247957+01:00 application=LogGeneratorSample message="Hello World Sample"

Clone this wiki locally