Skip to content

Commit c157e45

Browse files
authored
Merge pull request #55 from avireddy02/dev
Sample for CompactSplunkJsonFormatter
2 parents a6b73fa + 89454c2 commit c157e45

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

sample/Sample/Program.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Linq;
22
using Serilog;
3+
using Serilog.Sinks.Splunk;
34

45
namespace Sample
56
{
@@ -27,13 +28,35 @@ public static void Main(string[] args)
2728
OverridingSourceType(eventsToCreate);
2829
OverridingHost(eventsToCreate);
2930
WithNoTemplate(eventsToCreate);
30-
31+
WithCompactSplunkFormatter(eventsToCreate);
3132
if (runSSL)
3233
UsingSSL(eventsToCreate);
3334

3435
Log.Debug("Done");
3536
}
3637

38+
private static void WithCompactSplunkFormatter(int eventsToCreate)
39+
{
40+
// Vanilla Test with full uri specified
41+
Log.Logger = new LoggerConfiguration()
42+
.MinimumLevel.Debug()
43+
.WriteTo.LiterateConsole()
44+
.WriteTo.EventCollector(
45+
"http://localhost:8088/services/collector",
46+
Program.EventCollectorToken,new CompactSplunkJsonFormatter())
47+
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample", "ViaEventCollector")
48+
.Enrich.WithProperty("Serilog.Sinks.Splunk.Sample.TestType", "Vanilla with CompactSplunkJsonFormatter specified")
49+
.CreateLogger();
50+
51+
52+
foreach (var i in Enumerable.Range(0, eventsToCreate))
53+
{
54+
Log.Information("{Counter}{Message}", i, "Running vanilla loop with CompactSplunkJsonFormatter");
55+
}
56+
57+
Log.CloseAndFlush();
58+
}
59+
3760
public static void OverridingSource(int eventsToCreate)
3861
{
3962
// Override Source

0 commit comments

Comments
 (0)