1616using System . Net ;
1717using Serilog . Configuration ;
1818using Serilog . Events ;
19- using Serilog . Sinks . Splunk ;
20- using Splunk . Client ;
19+ using Serilog . Formatting . Display ;
20+ using Serilog . Sinks . Splunk ;
2121
2222namespace Serilog
2323{
2424 /// <summary>
25- /// Adds the WriteTo.SplunkViaHttp () extension method to <see cref="LoggerConfiguration"/>.
25+ /// Adds the WriteTo.SplunkViaEventCollector () extension method to <see cref="LoggerConfiguration"/>.
2626 /// </summary>
2727 public static class LoggerConfigurationSplunkExtensions
2828 {
2929 /// <summary>
30- /// Adds a sink that writes log events as to a Splunk instance via http.
31- /// </summary>
32- /// <param name="loggerConfiguration">The logger configuration.</param>
33- /// <param name="context">The Splunk context to log to</param>
34- /// <param name="batchInterval"></param>
35- /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
36- /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
37- /// <param name="batchSizeLimit">The size of the batch prior to writing</param>
38- /// <param name="renderTemplate">If true, the message template will be rendered</param>
39- /// <returns>Logger configuration, allowing configuration to continue.</returns>
40- /// <exception cref="ArgumentNullException">A required parameter is null.</exception>
41- /// <remarks>TODO: Add link to splunk configuration and wiki</remarks>
42- public static LoggerConfiguration SplunkViaHttp (
43- this LoggerSinkConfiguration loggerConfiguration ,
44- SplunkContext context ,
45- int batchSizeLimit ,
46- TimeSpan batchInterval ,
47- LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
48- IFormatProvider formatProvider = null ,
49- bool renderTemplate = true )
50- {
51- var sink = new SplunkViaHttpSink ( context , batchSizeLimit , batchInterval , formatProvider , renderTemplate ) ;
52-
53- return loggerConfiguration . Sink ( sink , restrictedToMinimumLevel ) ;
54- }
55-
56- /// <summary>
57- /// Adds a sink that writes log events as to a Splunk instance via http.
58- /// </summary>
59- /// <param name="loggerConfiguration">The logger configuration.</param>
60- /// <param name="context">The Splunk context to log to</param>
61- /// <param name="password">The password of the Splunk user</param>
62- /// <param name="resourceNameSpace"></param>
63- /// <param name="transmitterArgs"></param>
64- /// <param name="batchSizeLimit">The size of the batch prior to logging</param>
65- /// <param name="batchInterval">The interval on which to log via http</param>
66- /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
67- /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
68- /// <param name="index">The name of the Splunk index</param>
69- /// <param name="userName">The name of the Splunk user</param>
70- /// <param name="renderTemplate">If ture, the message template is rendered</param>
71- /// <returns>Logger configuration, allowing configuration to continue.</returns>
72- /// <exception cref="ArgumentNullException">A required parameter is null.</exception>
73- /// <remarks>TODO: Add link to splunk configuration and wiki</remarks>
74- public static LoggerConfiguration SplunkViaHttp (
75- this LoggerSinkConfiguration loggerConfiguration ,
76- Splunk . Client . Context context ,
77- string index ,
78- string userName ,
79- string password ,
80- int batchSizeLimit ,
81- TimeSpan batchInterval ,
82- Namespace resourceNameSpace ,
83- TransmitterArgs transmitterArgs ,
84- LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
85- IFormatProvider formatProvider = null ,
86- bool renderTemplate = true )
87- {
88- var sink = new SplunkViaHttpSink ( new SplunkContext ( context , index , userName , password , resourceNameSpace , transmitterArgs ) , batchSizeLimit , batchInterval , formatProvider ) ;
89-
90- return loggerConfiguration . Sink ( sink , restrictedToMinimumLevel ) ;
91- }
92-
93- /// <summary>
94- /// Adds a sink that writes log events as to a Splunk instance via http.
30+ /// Adds a sink that writes log events as to a Splunk instance via UDP.
9531 /// </summary>
9632 /// <param name="loggerConfiguration">The logger config</param>
9733 /// <param name="host">The Splunk host that is configured for UDP logging</param>
@@ -109,7 +45,7 @@ public static LoggerConfiguration SplunkViaUdp(
10945 IFormatProvider formatProvider = null ,
11046 bool renderTemplate = true )
11147 {
112- var sink = new SplunkViaUdpSink ( host , port , formatProvider , renderTemplate ) ;
48+ var sink = new UdpSink ( host , port , formatProvider , renderTemplate ) ;
11349
11450 return loggerConfiguration . Sink ( sink , restrictedToMinimumLevel ) ;
11551 }
@@ -134,7 +70,7 @@ public static LoggerConfiguration SplunkViaUdp(
13470 IFormatProvider formatProvider = null ,
13571 bool renderTemplate = true )
13672 {
137- var sink = new SplunkViaUdpSink ( hostAddresss , port , formatProvider , renderTemplate ) ;
73+ var sink = new UdpSink ( hostAddresss , port , formatProvider , renderTemplate ) ;
13874
13975 return loggerConfiguration . Sink ( sink , restrictedToMinimumLevel ) ;
14076 }
@@ -158,7 +94,7 @@ public static LoggerConfiguration SplunkViaTcp(
15894 IFormatProvider formatProvider = null ,
15995 bool renderTemplate = true )
16096 {
161- var sink = new SplunkViaTcpSink ( hostAddresss , port , formatProvider , renderTemplate ) ;
97+ var sink = new TcpSink ( hostAddresss , port , formatProvider , renderTemplate ) ;
16298
16399 return loggerConfiguration . Sink ( sink , restrictedToMinimumLevel ) ;
164100 }
@@ -182,7 +118,7 @@ public static LoggerConfiguration SplunkViaTcp(
182118 IFormatProvider formatProvider = null ,
183119 bool renderTemplate = true )
184120 {
185- var sink = new SplunkViaTcpSink ( host , port , formatProvider , renderTemplate ) ;
121+ var sink = new TcpSink ( host , port , formatProvider , renderTemplate ) ;
186122
187123 return loggerConfiguration . Sink ( sink , restrictedToMinimumLevel ) ;
188124 }
0 commit comments