From 53076c452a6c6ae8d59e90af2958d450e479d094 Mon Sep 17 00:00:00 2001 From: Matthew Erbs Date: Wed, 26 Oct 2016 07:32:04 +1000 Subject: [PATCH] Prep for release 2.1.1. * Updated changes.md * Updated sample with sourcetype example. --- CHANGES.md | 10 +++ sample/Program.cs | 157 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 119 insertions(+), 48 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b2dd806..7028702 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,13 @@ +##2.1.1 +- [#38](https://github.com/serilog/serilog-sinks-splunk/issues/38) +- Clean up of sample app using examples of host, sourcetype, source override + +##2.1.0 + +* Change to use a standalone formatter +* Resolves #32 & #26 by exposing `HttpMessageHandler` +* Resolves #30 by ignoring OSX build and including tests in `build.sh` for TravisCI + ##2.0 - Support for DotNet Core - Event Collector fluent interface changed to `.WriteTo.EventCollector` diff --git a/sample/Program.cs b/sample/Program.cs index 305543f..7ec94b7 100755 --- a/sample/Program.cs +++ b/sample/Program.cs @@ -5,94 +5,155 @@ namespace Sample { + /// + /// Sample 10 false + /// public class Program { - public static string EventCollectorToken = "1A4D65C9-601A-4717-AD6C-E1EC36A46B69"; + public static string EventCollectorToken = "2B94855F-1184-46F7-BFF1-56A3112F627E"; public static void Main(string[] args) { var eventsToCreate = 100; + var runSSL = false; if(args.Length > 0) eventsToCreate = int.Parse(args[0]); + if(args.Length == 2) + runSSL = bool.Parse(args[1]); + Log.Information("Sample starting up"); - Serilog.Debugging.SelfLog.Out = System.Console.Out; + Serilog.Debugging.SelfLog.Enable(System.Console.Out); - // Vanilla Tests just host + UsingHostOnly(eventsToCreate); + UsingFullUri(eventsToCreate); + OverridingSource(eventsToCreate); + OverridingSourceType(eventsToCreate); + OverridingHost(eventsToCreate); + WithNoTemplate(eventsToCreate); + + if(runSSL) + UsingSSL(eventsToCreate); + + Log.Debug("Done"); + } + + public static void OverridingSource(int eventsToCreate) + { + // Override Source Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.LiterateConsole() .WriteTo.EventCollector( - "http://localhost:8088", - Program.EventCollectorToken) + "http://localhost:8088", + Program.EventCollectorToken, + source: "Serilog.Sinks.Splunk.Sample.TestSource") .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector") - .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Vanilla No services/collector") - .CreateLogger(); - + .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Source Override") + .CreateLogger(); + foreach (var i in Enumerable.Range(0, eventsToCreate)) { - Log.Information("Running vanilla without extended endpoint loop {Counter}", i); + Log.Information("Running source override loop {Counter}", i); } Log.CloseAndFlush(); - // Vanilla Test with full uri specified + } + + public static void OverridingSourceType(int eventsToCreate) + { + // Override Source Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.LiterateConsole() .WriteTo.EventCollector( - "http://localhost:8088/services/collector", - Program.EventCollectorToken) + "http://localhost:8088", + Program.EventCollectorToken, + sourceType: "Serilog.Sinks.Splunk.Sample.TestSourceType") .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector") - .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Vanilla with full uri specified") - .CreateLogger(); - + .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Source Type Override") + .CreateLogger(); + foreach (var i in Enumerable.Range(0, eventsToCreate)) { - Log.Information("Running vanilla loop {Counter}", i); + Log.Information("Running source type override loop {Counter}", i); } Log.CloseAndFlush(); - // Override Source + } + + public static void OverridingHost(int eventsToCreate) + { + // Override Host Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.LiterateConsole() .WriteTo.EventCollector( "http://localhost:8088", Program.EventCollectorToken, - source: "Serilog.Sinks.Splunk.Sample") + host: "myamazingmachine") .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector") - .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Source Override") + .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Host Override") .CreateLogger(); foreach (var i in Enumerable.Range(0, eventsToCreate)) { - Log.Information("Running source override loop {Counter}", i); + Log.Information("Running host override loop {Counter}", i); } Log.CloseAndFlush(); - - // Override Host + + } + + public static void UsingFullUri(int eventsToCreate) + { + // Vanilla Test with full uri specified Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.LiterateConsole() .WriteTo.EventCollector( - "http://localhost:8088", - Program.EventCollectorToken, - host: "myamazingmachine") + "http://localhost:8088/services/collector", + Program.EventCollectorToken) .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector") - .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Host Override") + .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Vanilla with full uri specified") .CreateLogger(); - + + foreach (var i in Enumerable.Range(0, eventsToCreate)) { - Log.Information("Running host override loop {Counter}", i); - } + Log.Information("Running vanilla loop with full uri {Counter}", i); + } + + Log.CloseAndFlush(); + } + + public static void UsingHostOnly(int eventsToCreate) + { + // Vanilla Tests just host + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .WriteTo.LiterateConsole() + .WriteTo.EventCollector( + "http://localhost:8088", + Program.EventCollectorToken) + .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector") + .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Vanilla No services/collector in uri") + .CreateLogger(); + + foreach (var i in Enumerable.Range(0, eventsToCreate)) + { + Log.Information("Running vanilla without host name and port only {Counter}", i); + } + Log.CloseAndFlush(); + } - // No Template + public static void WithNoTemplate(int eventsToCreate) + { + // No Template Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.LiterateConsole() @@ -110,26 +171,26 @@ public static void Main(string[] args) } Log.CloseAndFlush(); + } - // // SSL - // Log.Logger = new LoggerConfiguration() - // .MinimumLevel.Debug() - // .WriteTo.LiterateConsole() - // .WriteTo.EventCollector( - // "https://localhost:8088", - // Program.EventCollectorToken) - // .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector") - // .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "HTTPS") - // .CreateLogger(); + public static void UsingSSL(int eventsToCreate) + { + // SSL + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .WriteTo.LiterateConsole() + .WriteTo.EventCollector( + "https://localhost:8088", + Program.EventCollectorToken) + .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector") + .Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "HTTPS") + .CreateLogger(); - // foreach (var i in Enumerable.Range(0, eventsToCreate)) - // { - // Log.Information("HTTPS {Counter}", i); - // } - // Log.CloseAndFlush(); - - Log.Debug("Done"); - + foreach (var i in Enumerable.Range(0, eventsToCreate)) + { + Log.Information("HTTPS {Counter}", i); + } + Log.CloseAndFlush(); } } }