diff --git a/BetterStack.Logs.Serilog.csproj b/BetterStack.Logs.Serilog.csproj index 252d583..240dc3f 100644 --- a/BetterStack.Logs.Serilog.csproj +++ b/BetterStack.Logs.Serilog.csproj @@ -1,7 +1,7 @@ BetterStack.Logs.Serilog - 1.0.0 + 1.1.0 Simon Rozsival, Tomas Hromada Better Stack LICENSE.md @@ -39,7 +39,7 @@ - + diff --git a/BetterStack.Logs.Serilog/BetterStackHttpClient.cs b/BetterStack.Logs.Serilog/BetterStackHttpClient.cs index 9fede42..dc3d1fa 100644 --- a/BetterStack.Logs.Serilog/BetterStackHttpClient.cs +++ b/BetterStack.Logs.Serilog/BetterStackHttpClient.cs @@ -4,6 +4,7 @@ using System.Net.Http.Headers; using System.Net.Http; using System.Threading.Tasks; +using System.Threading; using System; namespace BetterStack.Logs.Serilog @@ -40,11 +41,17 @@ public virtual void Configure(IConfiguration configuration) /// public virtual async Task PostAsync(string requestUri, Stream contentStream) { - var content = new StreamContent(contentStream); - content.Headers.Add("Content-Type", "application/json"); + return await PostAsync(requestUri, contentStream, CancellationToken.None); + } + + /// + public virtual async Task PostAsync(string requestUri, Stream contentStream, CancellationToken cancellationToken) + { + using var content = new StreamContent(contentStream); + content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = await httpClient - .PostAsync(requestUri, content) + .PostAsync(requestUri, content, cancellationToken) .ConfigureAwait(false); return response; diff --git a/BetterStack.Logs.Serilog/LoggerSinkConfigurationExtensions.cs b/BetterStack.Logs.Serilog/LoggerSinkConfigurationExtensions.cs index ae38cff..0e3d7e0 100644 --- a/BetterStack.Logs.Serilog/LoggerSinkConfigurationExtensions.cs +++ b/BetterStack.Logs.Serilog/LoggerSinkConfigurationExtensions.cs @@ -65,6 +65,7 @@ public static LoggerConfiguration BetterStack( logEventsInBatchLimit: batchSize, batchSizeLimitBytes: null, period: batchInterval.Value, + flushOnClose: true, textFormatter: new BetterStackTextFormatter(), batchFormatter: new ArrayBatchFormatter(), httpClient: new BetterStackHttpClient(sourceToken));