16
16
using System . Net ;
17
17
using Serilog . Configuration ;
18
18
using Serilog . Events ;
19
- using Serilog . Sinks . Splunk ;
20
- using Splunk . Client ;
19
+ using Serilog . Formatting . Display ;
20
+ using Serilog . Sinks . Splunk ;
21
21
22
22
namespace Serilog
23
23
{
24
24
/// <summary>
25
- /// Adds the WriteTo.SplunkViaHttp () extension method to <see cref="LoggerConfiguration"/>.
25
+ /// Adds the WriteTo.SplunkViaEventCollector () extension method to <see cref="LoggerConfiguration"/>.
26
26
/// </summary>
27
27
public static class LoggerConfigurationSplunkExtensions
28
28
{
29
29
/// <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.
95
31
/// </summary>
96
32
/// <param name="loggerConfiguration">The logger config</param>
97
33
/// <param name="host">The Splunk host that is configured for UDP logging</param>
@@ -109,7 +45,7 @@ public static LoggerConfiguration SplunkViaUdp(
109
45
IFormatProvider formatProvider = null ,
110
46
bool renderTemplate = true )
111
47
{
112
- var sink = new SplunkViaUdpSink ( host , port , formatProvider , renderTemplate ) ;
48
+ var sink = new UdpSink ( host , port , formatProvider , renderTemplate ) ;
113
49
114
50
return loggerConfiguration . Sink ( sink , restrictedToMinimumLevel ) ;
115
51
}
@@ -134,7 +70,7 @@ public static LoggerConfiguration SplunkViaUdp(
134
70
IFormatProvider formatProvider = null ,
135
71
bool renderTemplate = true )
136
72
{
137
- var sink = new SplunkViaUdpSink ( hostAddresss , port , formatProvider , renderTemplate ) ;
73
+ var sink = new UdpSink ( hostAddresss , port , formatProvider , renderTemplate ) ;
138
74
139
75
return loggerConfiguration . Sink ( sink , restrictedToMinimumLevel ) ;
140
76
}
@@ -158,7 +94,7 @@ public static LoggerConfiguration SplunkViaTcp(
158
94
IFormatProvider formatProvider = null ,
159
95
bool renderTemplate = true )
160
96
{
161
- var sink = new SplunkViaTcpSink ( hostAddresss , port , formatProvider , renderTemplate ) ;
97
+ var sink = new TcpSink ( hostAddresss , port , formatProvider , renderTemplate ) ;
162
98
163
99
return loggerConfiguration . Sink ( sink , restrictedToMinimumLevel ) ;
164
100
}
@@ -182,7 +118,7 @@ public static LoggerConfiguration SplunkViaTcp(
182
118
IFormatProvider formatProvider = null ,
183
119
bool renderTemplate = true )
184
120
{
185
- var sink = new SplunkViaTcpSink ( host , port , formatProvider , renderTemplate ) ;
121
+ var sink = new TcpSink ( host , port , formatProvider , renderTemplate ) ;
186
122
187
123
return loggerConfiguration . Sink ( sink , restrictedToMinimumLevel ) ;
188
124
}
0 commit comments