Skip to content

Commit 01a1b4d

Browse files
authored
Upgrade to Serilog.Sinks.Http 9.0.0 (#6)
1 parent 132e6a6 commit 01a1b4d

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

BetterStack.Logs.Serilog.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<PackageId>BetterStack.Logs.Serilog</PackageId>
4-
<Version>1.0.0</Version>
4+
<Version>1.1.0</Version>
55
<Authors>Simon Rozsival, Tomas Hromada</Authors>
66
<Company>Better Stack</Company>
77
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
@@ -39,7 +39,7 @@
3939
<ItemGroup>
4040
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
4141
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
42-
<PackageReference Include="Serilog.Sinks.Http" Version="8.0.0" />
42+
<PackageReference Include="Serilog.Sinks.Http" Version="9.0.0" />
4343
</ItemGroup>
4444

4545
<ItemGroup>

BetterStack.Logs.Serilog/BetterStackHttpClient.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Net.Http.Headers;
55
using System.Net.Http;
66
using System.Threading.Tasks;
7+
using System.Threading;
78
using System;
89

910
namespace BetterStack.Logs.Serilog
@@ -40,11 +41,17 @@ public virtual void Configure(IConfiguration configuration)
4041
/// <inheritdoc />
4142
public virtual async Task<HttpResponseMessage> PostAsync(string requestUri, Stream contentStream)
4243
{
43-
var content = new StreamContent(contentStream);
44-
content.Headers.Add("Content-Type", "application/json");
44+
return await PostAsync(requestUri, contentStream, CancellationToken.None);
45+
}
46+
47+
/// <inheritdoc />
48+
public virtual async Task<HttpResponseMessage> PostAsync(string requestUri, Stream contentStream, CancellationToken cancellationToken)
49+
{
50+
using var content = new StreamContent(contentStream);
51+
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
4552

4653
var response = await httpClient
47-
.PostAsync(requestUri, content)
54+
.PostAsync(requestUri, content, cancellationToken)
4855
.ConfigureAwait(false);
4956

5057
return response;

BetterStack.Logs.Serilog/LoggerSinkConfigurationExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public static LoggerConfiguration BetterStack(
6565
logEventsInBatchLimit: batchSize,
6666
batchSizeLimitBytes: null,
6767
period: batchInterval.Value,
68+
flushOnClose: true,
6869
textFormatter: new BetterStackTextFormatter(),
6970
batchFormatter: new ArrayBatchFormatter(),
7071
httpClient: new BetterStackHttpClient(sourceToken));

0 commit comments

Comments
 (0)