25
25
using Serilog . Formatting ;
26
26
using Serilog . Formatting . Json ;
27
27
using Serilog . Sinks . AzureTableStorage ;
28
- using Serilog . Sinks . PeriodicBatching ;
29
28
30
29
namespace Serilog ;
31
30
@@ -53,7 +52,6 @@ public static class LoggerConfigurationAzureTableStorageExtensions
53
52
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
54
53
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
55
54
/// <param name="storageTableName">Table name that log entries will be written to. Note: Optional, setting this may impact performance</param>
56
- /// <param name="writeInBatches">Use a periodic batching sink, as opposed to a synchronous one-at-a-time sink</param>
57
55
/// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
58
56
/// <param name="period">The time to wait between checking for event batches.</param>
59
57
/// <param name="keyGenerator">The key generator used to create the PartitionKey and the RowKey for each log entry</param>
@@ -70,7 +68,6 @@ public static LoggerConfiguration AzureTableStorage(
70
68
LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
71
69
IFormatProvider formatProvider = null ,
72
70
string storageTableName = null ,
73
- bool writeInBatches = true ,
74
71
TimeSpan ? period = null ,
75
72
int ? batchPostingLimit = null ,
76
73
IKeyGenerator keyGenerator = null ,
@@ -92,7 +89,6 @@ public static LoggerConfiguration AzureTableStorage(
92
89
restrictedToMinimumLevel : restrictedToMinimumLevel ,
93
90
formatProvider : formatProvider ,
94
91
storageTableName : storageTableName ,
95
- writeInBatches : writeInBatches ,
96
92
period : period ,
97
93
batchPostingLimit : batchPostingLimit ,
98
94
keyGenerator : keyGenerator ,
@@ -111,7 +107,6 @@ public static LoggerConfiguration AzureTableStorage(
111
107
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
112
108
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
113
109
/// <param name="storageTableName">Table name that log entries will be written to. Note: Optional, setting this may impact performance</param>
114
- /// <param name="writeInBatches">Use a periodic batching sink, as opposed to a synchronous one-at-a-time sink</param>
115
110
/// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
116
111
/// <param name="period">The time to wait between checking for event batches.</param>
117
112
/// <param name="keyGenerator">The key generator used to create the PartitionKey and the RowKey for each log entry</param>
@@ -128,7 +123,6 @@ public static LoggerConfiguration AzureTableStorage(
128
123
LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
129
124
IFormatProvider formatProvider = null ,
130
125
string storageTableName = null ,
131
- bool writeInBatches = true ,
132
126
TimeSpan ? period = null ,
133
127
int ? batchPostingLimit = null ,
134
128
IKeyGenerator keyGenerator = null ,
@@ -150,7 +144,6 @@ public static LoggerConfiguration AzureTableStorage(
150
144
restrictedToMinimumLevel : restrictedToMinimumLevel ,
151
145
formatProvider : formatProvider ,
152
146
storageTableName : storageTableName ,
153
- writeInBatches : writeInBatches ,
154
147
period : period ,
155
148
batchPostingLimit : batchPostingLimit ,
156
149
keyGenerator : keyGenerator ,
@@ -171,7 +164,6 @@ public static LoggerConfiguration AzureTableStorage(
171
164
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
172
165
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
173
166
/// <param name="storageTableName">Table name that log entries will be written to. Note: Optional, setting this may impact performance</param>
174
- /// <param name="writeInBatches">Use a periodic batching sink, as opposed to a synchronous one-at-a-time sink</param>
175
167
/// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
176
168
/// <param name="period">The time to wait between checking for event batches.</param>
177
169
/// <param name="keyGenerator">The key generator used to create the PartitionKey and the RowKey for each log entry</param>
@@ -189,7 +181,6 @@ public static LoggerConfiguration AzureTableStorage(
189
181
LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
190
182
IFormatProvider formatProvider = null ,
191
183
string storageTableName = null ,
192
- bool writeInBatches = true ,
193
184
TimeSpan ? period = null ,
194
185
int ? batchPostingLimit = null ,
195
186
IKeyGenerator keyGenerator = null ,
@@ -214,7 +205,6 @@ public static LoggerConfiguration AzureTableStorage(
214
205
restrictedToMinimumLevel : restrictedToMinimumLevel ,
215
206
formatProvider : formatProvider ,
216
207
storageTableName : storageTableName ,
217
- writeInBatches : writeInBatches ,
218
208
period : period ,
219
209
batchPostingLimit : batchPostingLimit ,
220
210
keyGenerator : keyGenerator ,
@@ -233,7 +223,6 @@ public static LoggerConfiguration AzureTableStorage(
233
223
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
234
224
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
235
225
/// <param name="storageTableName">Table name that log entries will be written to. Note: Optional, setting this may impact performance</param>
236
- /// <param name="writeInBatches">Use a periodic batching sink, as opposed to a synchronous one-at-a-time sink;</param>
237
226
/// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
238
227
/// <param name="period">The time to wait between checking for event batches.</param>
239
228
/// <param name="keyGenerator">The key generator used to create the PartitionKey and the RowKey for each log entry</param>
@@ -251,7 +240,6 @@ public static LoggerConfiguration AzureTableStorage(
251
240
LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
252
241
IFormatProvider formatProvider = null ,
253
242
string storageTableName = null ,
254
- bool writeInBatches = true ,
255
243
TimeSpan ? period = null ,
256
244
int ? batchPostingLimit = null ,
257
245
IKeyGenerator keyGenerator = null ,
@@ -268,7 +256,6 @@ public static LoggerConfiguration AzureTableStorage(
268
256
if ( storageAccount == null )
269
257
throw new ArgumentNullException ( nameof ( storageAccount ) ) ;
270
258
271
- ILogEventSink sink ;
272
259
try
273
260
{
274
261
var options = new AzureTableStorageSinkOptions
@@ -292,30 +279,22 @@ public static LoggerConfiguration AzureTableStorage(
292
279
keyGenerator : keyGenerator ,
293
280
tableClientFactory : tableClientFactory ) ;
294
281
295
- if ( writeInBatches )
282
+ var batchingOptions = new BatchingOptions
296
283
{
297
- // wrap in PeriodicBatchingSink
298
- var batchingOptions = new PeriodicBatchingSinkOptions
299
- {
300
- BatchSizeLimit = batchPostingLimit ?? DefaultBatchSizeLimit ,
301
- EagerlyEmitFirstEvent = true ,
302
- Period = period ?? DefaultPeriod ,
303
- } ;
304
-
305
- sink = new PeriodicBatchingSink ( tableStorageSink , batchingOptions ) ;
306
- }
307
- else
308
- {
309
- sink = tableStorageSink ;
310
- }
284
+ BatchSizeLimit = batchPostingLimit ?? DefaultBatchSizeLimit ,
285
+ EagerlyEmitFirstEvent = true ,
286
+ BufferingTimeLimit = period ?? DefaultPeriod ,
287
+ } ;
288
+
289
+ return loggerConfiguration . Sink ( tableStorageSink , batchingOptions , restrictedToMinimumLevel ) ;
311
290
}
312
291
catch ( Exception ex )
313
292
{
314
293
Debugging . SelfLog . WriteLine ( $ "Error configuring AzureTableStorage: { ex } ") ;
315
- sink = new LoggerConfiguration ( ) . CreateLogger ( ) ;
294
+ var sink = new LoggerConfiguration ( ) . CreateLogger ( ) ;
295
+ return loggerConfiguration . Sink ( sink ) ;
316
296
}
317
297
318
- return loggerConfiguration . Sink ( sink , restrictedToMinimumLevel ) ;
319
298
}
320
299
321
300
/// <summary>
@@ -327,7 +306,6 @@ public static LoggerConfiguration AzureTableStorage(
327
306
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
328
307
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
329
308
/// <param name="storageTableName">Table name that log entries will be written to. Note: Optional, setting this may impact performance</param>
330
- /// <param name="writeInBatches">Use a periodic batching sink, as opposed to a synchronous one-at-a-time sink</param>
331
309
/// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
332
310
/// <param name="period">The time to wait between checking for event batches.</param>
333
311
/// <param name="keyGenerator">The key generator used to create the PartitionKey and the RowKey for each log entry</param>
@@ -345,7 +323,6 @@ public static LoggerConfiguration AzureTableStorage(
345
323
LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
346
324
IFormatProvider formatProvider = null ,
347
325
string storageTableName = null ,
348
- bool writeInBatches = true ,
349
326
TimeSpan ? period = null ,
350
327
int ? batchPostingLimit = null ,
351
328
IKeyGenerator keyGenerator = null ,
@@ -373,7 +350,6 @@ public static LoggerConfiguration AzureTableStorage(
373
350
restrictedToMinimumLevel : restrictedToMinimumLevel ,
374
351
formatProvider : formatProvider ,
375
352
storageTableName : storageTableName ,
376
- writeInBatches : writeInBatches ,
377
353
period : period ,
378
354
batchPostingLimit : batchPostingLimit ,
379
355
keyGenerator : keyGenerator ,
@@ -404,7 +380,6 @@ public static LoggerConfiguration AzureTableStorage(
404
380
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
405
381
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
406
382
/// <param name="storageTableName">Table name that log entries will be written to. Note: Optional, setting this may impact performance</param>
407
- /// <param name="writeInBatches">Use a periodic batching sink, as opposed to a synchronous one-at-a-time sink</param>
408
383
/// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
409
384
/// <param name="period">The time to wait between checking for event batches.</param>
410
385
/// <param name="keyGenerator">The key generator used to create the PartitionKey and the RowKey for each log entry</param>
@@ -423,7 +398,6 @@ public static LoggerConfiguration AzureTableStorage(
423
398
LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
424
399
IFormatProvider formatProvider = null ,
425
400
string storageTableName = null ,
426
- bool writeInBatches = true ,
427
401
TimeSpan ? period = null ,
428
402
int ? batchPostingLimit = null ,
429
403
IKeyGenerator keyGenerator = null ,
@@ -460,7 +434,6 @@ public static LoggerConfiguration AzureTableStorage(
460
434
restrictedToMinimumLevel : restrictedToMinimumLevel ,
461
435
formatProvider : formatProvider ,
462
436
storageTableName : storageTableName ,
463
- writeInBatches : writeInBatches ,
464
437
period : period ,
465
438
batchPostingLimit : batchPostingLimit ,
466
439
keyGenerator : keyGenerator ,
0 commit comments