2525using Serilog . Formatting ;
2626using Serilog . Formatting . Json ;
2727using Serilog . Sinks . AzureTableStorage ;
28- using Serilog . Sinks . PeriodicBatching ;
2928
3029namespace Serilog ;
3130
@@ -53,7 +52,6 @@ public static class LoggerConfigurationAzureTableStorageExtensions
5352 /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
5453 /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
5554 /// <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>
5755 /// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
5856 /// <param name="period">The time to wait between checking for event batches.</param>
5957 /// <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(
7068 LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
7169 IFormatProvider formatProvider = null ,
7270 string storageTableName = null ,
73- bool writeInBatches = true ,
7471 TimeSpan ? period = null ,
7572 int ? batchPostingLimit = null ,
7673 IKeyGenerator keyGenerator = null ,
@@ -92,7 +89,6 @@ public static LoggerConfiguration AzureTableStorage(
9289 restrictedToMinimumLevel : restrictedToMinimumLevel ,
9390 formatProvider : formatProvider ,
9491 storageTableName : storageTableName ,
95- writeInBatches : writeInBatches ,
9692 period : period ,
9793 batchPostingLimit : batchPostingLimit ,
9894 keyGenerator : keyGenerator ,
@@ -111,7 +107,6 @@ public static LoggerConfiguration AzureTableStorage(
111107 /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
112108 /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
113109 /// <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>
115110 /// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
116111 /// <param name="period">The time to wait between checking for event batches.</param>
117112 /// <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(
128123 LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
129124 IFormatProvider formatProvider = null ,
130125 string storageTableName = null ,
131- bool writeInBatches = true ,
132126 TimeSpan ? period = null ,
133127 int ? batchPostingLimit = null ,
134128 IKeyGenerator keyGenerator = null ,
@@ -150,7 +144,6 @@ public static LoggerConfiguration AzureTableStorage(
150144 restrictedToMinimumLevel : restrictedToMinimumLevel ,
151145 formatProvider : formatProvider ,
152146 storageTableName : storageTableName ,
153- writeInBatches : writeInBatches ,
154147 period : period ,
155148 batchPostingLimit : batchPostingLimit ,
156149 keyGenerator : keyGenerator ,
@@ -171,7 +164,6 @@ public static LoggerConfiguration AzureTableStorage(
171164 /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
172165 /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
173166 /// <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>
175167 /// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
176168 /// <param name="period">The time to wait between checking for event batches.</param>
177169 /// <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(
189181 LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
190182 IFormatProvider formatProvider = null ,
191183 string storageTableName = null ,
192- bool writeInBatches = true ,
193184 TimeSpan ? period = null ,
194185 int ? batchPostingLimit = null ,
195186 IKeyGenerator keyGenerator = null ,
@@ -214,7 +205,6 @@ public static LoggerConfiguration AzureTableStorage(
214205 restrictedToMinimumLevel : restrictedToMinimumLevel ,
215206 formatProvider : formatProvider ,
216207 storageTableName : storageTableName ,
217- writeInBatches : writeInBatches ,
218208 period : period ,
219209 batchPostingLimit : batchPostingLimit ,
220210 keyGenerator : keyGenerator ,
@@ -233,7 +223,6 @@ public static LoggerConfiguration AzureTableStorage(
233223 /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
234224 /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
235225 /// <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>
237226 /// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
238227 /// <param name="period">The time to wait between checking for event batches.</param>
239228 /// <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(
251240 LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
252241 IFormatProvider formatProvider = null ,
253242 string storageTableName = null ,
254- bool writeInBatches = true ,
255243 TimeSpan ? period = null ,
256244 int ? batchPostingLimit = null ,
257245 IKeyGenerator keyGenerator = null ,
@@ -268,7 +256,6 @@ public static LoggerConfiguration AzureTableStorage(
268256 if ( storageAccount == null )
269257 throw new ArgumentNullException ( nameof ( storageAccount ) ) ;
270258
271- ILogEventSink sink ;
272259 try
273260 {
274261 var options = new AzureTableStorageSinkOptions
@@ -292,30 +279,22 @@ public static LoggerConfiguration AzureTableStorage(
292279 keyGenerator : keyGenerator ,
293280 tableClientFactory : tableClientFactory ) ;
294281
295- if ( writeInBatches )
282+ var batchingOptions = new BatchingOptions
296283 {
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 ) ;
311290 }
312291 catch ( Exception ex )
313292 {
314293 Debugging . SelfLog . WriteLine ( $ "Error configuring AzureTableStorage: { ex } ") ;
315- sink = new LoggerConfiguration ( ) . CreateLogger ( ) ;
294+ var sink = new LoggerConfiguration ( ) . CreateLogger ( ) ;
295+ return loggerConfiguration . Sink ( sink ) ;
316296 }
317297
318- return loggerConfiguration . Sink ( sink , restrictedToMinimumLevel ) ;
319298 }
320299
321300 /// <summary>
@@ -327,7 +306,6 @@ public static LoggerConfiguration AzureTableStorage(
327306 /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
328307 /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
329308 /// <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>
331309 /// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
332310 /// <param name="period">The time to wait between checking for event batches.</param>
333311 /// <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(
345323 LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
346324 IFormatProvider formatProvider = null ,
347325 string storageTableName = null ,
348- bool writeInBatches = true ,
349326 TimeSpan ? period = null ,
350327 int ? batchPostingLimit = null ,
351328 IKeyGenerator keyGenerator = null ,
@@ -373,7 +350,6 @@ public static LoggerConfiguration AzureTableStorage(
373350 restrictedToMinimumLevel : restrictedToMinimumLevel ,
374351 formatProvider : formatProvider ,
375352 storageTableName : storageTableName ,
376- writeInBatches : writeInBatches ,
377353 period : period ,
378354 batchPostingLimit : batchPostingLimit ,
379355 keyGenerator : keyGenerator ,
@@ -404,7 +380,6 @@ public static LoggerConfiguration AzureTableStorage(
404380 /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
405381 /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
406382 /// <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>
408383 /// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
409384 /// <param name="period">The time to wait between checking for event batches.</param>
410385 /// <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(
423398 LogEventLevel restrictedToMinimumLevel = LevelAlias . Minimum ,
424399 IFormatProvider formatProvider = null ,
425400 string storageTableName = null ,
426- bool writeInBatches = true ,
427401 TimeSpan ? period = null ,
428402 int ? batchPostingLimit = null ,
429403 IKeyGenerator keyGenerator = null ,
@@ -460,7 +434,6 @@ public static LoggerConfiguration AzureTableStorage(
460434 restrictedToMinimumLevel : restrictedToMinimumLevel ,
461435 formatProvider : formatProvider ,
462436 storageTableName : storageTableName ,
463- writeInBatches : writeInBatches ,
464437 period : period ,
465438 batchPostingLimit : batchPostingLimit ,
466439 keyGenerator : keyGenerator ,
0 commit comments