From 89454c2e65449b6190a3431d41494f7e71b4a188 Mon Sep 17 00:00:00 2001 From: avireddy02 Date: Thu, 25 May 2017 20:50:14 -0700 Subject: [PATCH] Sample for CompactSplunkJsonFormatter --- sample/Sample/Program.cs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/sample/Sample/Program.cs b/sample/Sample/Program.cs index 5cc145c..18050a9 100644 --- a/sample/Sample/Program.cs +++ b/sample/Sample/Program.cs @@ -1,5 +1,6 @@ using System.Linq; using Serilog; +using Serilog.Sinks.Splunk; namespace Sample { @@ -27,13 +28,35 @@ public static void Main(string[] args) OverridingSourceType(eventsToCreate); OverridingHost(eventsToCreate); WithNoTemplate(eventsToCreate); - + WithCompactSplunkFormatter(eventsToCreate); if (runSSL) UsingSSL(eventsToCreate); Log.Debug("Done"); } + private static void WithCompactSplunkFormatter(int eventsToCreate) + { + // Vanilla Test with full uri specified + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .WriteTo.LiterateConsole() + .WriteTo.EventCollector( + "http://localhost:8088/services/collector", + Program.EventCollectorToken,new CompactSplunkJsonFormatter()) + .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector") + .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Vanilla with CompactSplunkJsonFormatter specified") + .CreateLogger(); + + + foreach (var i in Enumerable.Range(0, eventsToCreate)) + { + Log.Information("{Counter}{Message}", i, "Running vanilla loop with CompactSplunkJsonFormatter"); + } + + Log.CloseAndFlush(); + } + public static void OverridingSource(int eventsToCreate) { // Override Source