16
16
using System ;
17
17
using System . Net . Http ;
18
18
using Serilog . Configuration ;
19
+ using Serilog . Core ;
19
20
using Serilog . Events ;
20
21
using Serilog . Formatting ;
21
22
using Serilog . Sinks . Splunk ;
@@ -53,6 +54,7 @@ public static class SplunkLoggingConfigurationExtensions
53
54
/// <param name="batchIntervalInSeconds">The interval in seconds that the queue should be instpected for batching</param>
54
55
/// <param name="batchSizeLimit">The size of the batch</param>
55
56
/// <param name="messageHandler">The handler used to send HTTP requests</param>
57
+ /// <param name="levelSwitch">A switch allowing the pass-through minimum level to be changed at runtime.</param>
56
58
/// <returns></returns>
57
59
public static LoggerConfiguration EventCollector (
58
60
this LoggerSinkConfiguration configuration ,
@@ -69,7 +71,8 @@ public static LoggerConfiguration EventCollector(
69
71
bool renderTemplate = true ,
70
72
int batchIntervalInSeconds = 2 ,
71
73
int batchSizeLimit = 100 ,
72
- HttpMessageHandler messageHandler = null )
74
+ HttpMessageHandler messageHandler = null ,
75
+ LoggingLevelSwitch levelSwitch = null )
73
76
{
74
77
if ( configuration == null ) throw new ArgumentNullException ( nameof ( configuration ) ) ;
75
78
if ( outputTemplate == null ) throw new ArgumentNullException ( nameof ( outputTemplate ) ) ;
@@ -88,7 +91,7 @@ public static LoggerConfiguration EventCollector(
88
91
renderTemplate ,
89
92
messageHandler ) ;
90
93
91
- return configuration . Sink ( eventCollectorSink , restrictedToMinimumLevel ) ;
94
+ return configuration . Sink ( eventCollectorSink , restrictedToMinimumLevel , levelSwitch ) ;
92
95
}
93
96
94
97
/// <summary>
@@ -104,6 +107,7 @@ public static LoggerConfiguration EventCollector(
104
107
/// <param name="batchIntervalInSeconds">The interval in seconds that the queue should be instpected for batching</param>
105
108
/// <param name="batchSizeLimit">The size of the batch</param>
106
109
/// <param name="messageHandler">The handler used to send HTTP requests</param>
110
+ /// <param name="levelSwitch">A switch allowing the pass-through minimum level to be changed at runtime.</param>
107
111
/// <returns></returns>
108
112
public static LoggerConfiguration EventCollector (
109
113
this LoggerSinkConfiguration configuration ,
@@ -115,7 +119,8 @@ public static LoggerConfiguration EventCollector(
115
119
string outputTemplate = DefaultOutputTemplate ,
116
120
int batchIntervalInSeconds = 2 ,
117
121
int batchSizeLimit = 100 ,
118
- HttpMessageHandler messageHandler = null )
122
+ HttpMessageHandler messageHandler = null ,
123
+ LoggingLevelSwitch levelSwitch = null )
119
124
{
120
125
if ( configuration == null ) throw new ArgumentNullException ( nameof ( configuration ) ) ;
121
126
if ( jsonFormatter == null ) throw new ArgumentNullException ( nameof ( jsonFormatter ) ) ;
@@ -130,10 +135,10 @@ public static LoggerConfiguration EventCollector(
130
135
jsonFormatter ,
131
136
messageHandler ) ;
132
137
133
- return configuration . Sink ( eventCollectorSink , restrictedToMinimumLevel ) ;
138
+ return configuration . Sink ( eventCollectorSink , restrictedToMinimumLevel , levelSwitch ) ;
134
139
}
135
140
136
-
141
+
137
142
/// <summary>
138
143
/// Adds a sink that writes log events as to a Splunk instance via the HTTP Event Collector.
139
144
/// </summary>
@@ -152,6 +157,7 @@ public static LoggerConfiguration EventCollector(
152
157
/// <param name="batchIntervalInSeconds">The interval in seconds that the queue should be instpected for batching</param>
153
158
/// <param name="batchSizeLimit">The size of the batch</param>
154
159
/// <param name="messageHandler">The handler used to send HTTP requests</param>
160
+ /// <param name="levelSwitch">A switch allowing the pass-through minimum level to be changed at runtime.</param>
155
161
/// <param name="fields">Customfields that will be indexed in splunk with this event</param>
156
162
/// <returns></returns>
157
163
public static LoggerConfiguration EventCollector (
@@ -170,7 +176,8 @@ public static LoggerConfiguration EventCollector(
170
176
bool renderTemplate = true ,
171
177
int batchIntervalInSeconds = 2 ,
172
178
int batchSizeLimit = 100 ,
173
- HttpMessageHandler messageHandler = null )
179
+ HttpMessageHandler messageHandler = null ,
180
+ LoggingLevelSwitch levelSwitch = null )
174
181
{
175
182
if ( configuration == null ) throw new ArgumentNullException ( nameof ( configuration ) ) ;
176
183
if ( outputTemplate == null ) throw new ArgumentNullException ( nameof ( outputTemplate ) ) ;
@@ -191,7 +198,7 @@ public static LoggerConfiguration EventCollector(
191
198
messageHandler
192
199
) ;
193
200
194
- return configuration . Sink ( eventCollectorSink , restrictedToMinimumLevel ) ;
201
+ return configuration . Sink ( eventCollectorSink , restrictedToMinimumLevel , levelSwitch ) ;
195
202
}
196
203
}
197
204
}
0 commit comments