Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions BetterStack.Logs.Serilog.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>BetterStack.Logs.Serilog</PackageId>
<Version>1.0.0</Version>
<Version>1.1.0</Version>
<Authors>Simon Rozsival, Tomas Hromada</Authors>
<Company>Better Stack</Company>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
Expand Down Expand Up @@ -39,7 +39,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Http" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Http" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 10 additions & 3 deletions BetterStack.Logs.Serilog/BetterStackHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -40,11 +41,17 @@ public virtual void Configure(IConfiguration configuration)
/// <inheritdoc />
public virtual async Task<HttpResponseMessage> PostAsync(string requestUri, Stream contentStream)
{
var content = new StreamContent(contentStream);
content.Headers.Add("Content-Type", "application/json");
return await PostAsync(requestUri, contentStream, CancellationToken.None);
}

/// <inheritdoc />
public virtual async Task<HttpResponseMessage> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down