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
2 changes: 1 addition & 1 deletion src/Serilog.Sinks.Grafana.Loki/Models/LokiBatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ public LokiStream CreateStream()
return stream;
}

public string Serialize() => JsonSerializer.Serialize(this);
public string Serialize() => JsonSerializer.Serialize(this, LokiSerializationContext.Default.LokiBatch);
}
18 changes: 18 additions & 0 deletions src/Serilog.Sinks.Grafana.Loki/Models/LokiSerializationContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2020-2022 Mykhailo Shevchuk & Contributors
//
// Licensed under the MIT license;
// you may not use this file except in compliance with the License.
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See LICENSE file in the project root for full license information.

using System.Text.Json.Serialization;

namespace Serilog.Sinks.Grafana.Loki.Models;

[JsonSerializable(typeof(LokiBatch))]
internal sealed partial class LokiSerializationContext : JsonSerializerContext
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

<ItemGroup>
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="System.Text.Json" Version="4.7.0" />
<PackageReference Include="System.Text.Json" Version="8.0.5"
Condition="'$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'net5.0'" />
</ItemGroup>

<ItemGroup>
Expand Down