Skip to content

Fix serialization of Serilog.Sinks not including log.level #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
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
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ resharper_csharp_accessor_owner_body=expression_body

resharper_redundant_case_label_highlighting=do_not_show
resharper_redundant_argument_default_value_highlighting=do_not_show
dotnet_diagnostic.xUnit1041.severity = none

[*.{sh,bat,ps1}]
trim_trailing_whitespace=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.0" />
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.4.3" />
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.6.0" />
<PackageReference Include="NEST" Version="7.8.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<PackageReference Include="Elastic.Apm" Version="1.22.0" />
<PackageReference Include="Serilog" Version="4.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.4.3" />
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.16.2" />
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.6.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.4.3" />
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.6.0" />
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.16.2" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion examples/playground/playground.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.5.0" />
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.6.0" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions src/Elastic.CommonSchema.Serilog/LogEventConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.Json.Serialization;
using Elastic.CommonSchema.Serialization;
using Serilog.Events;
using static Elastic.CommonSchema.Serilog.SpecialProperties;

namespace Elastic.CommonSchema.Serilog
{
/// A specialized instance of <see cref="EcsDocument"/> that holds on to the original <see cref="LogEvent"/>
/// <para> This property won't be emitted to JSON but is used to report back to serilog failure pipelines</para>
[JsonConverter(typeof(EcsDocumentJsonConverterFactory))]
public class LogEventEcsDocument : EcsDocument
{
/// The original <see cref="LogEvent"/> for bookkeeping, not send over to Elasticsearch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,5 @@ private static void WriteTimestamp(Utf8JsonWriter writer, BaseFieldSet value, Js
/// <summary> A JsonConverter for <see cref="EcsDocument"/> that supports the
/// https://github.com/elastic/ecs-logging specification
/// </summary>
public class EcsDocumentJsonConverter : EcsDocumentJsonConverter<EcsDocument>
{
}
public class EcsDocumentJsonConverter : EcsDocumentJsonConverter<EcsDocument>;
}
3 changes: 2 additions & 1 deletion tests-integration/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\build\keys\keypair.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<NoWarn>xUnit1041</NoWarn>
</PropertyGroup>
<ItemGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(ProjectName), '^(.*)Tests$'))">

<PackageReference Include="JunitXml.TestLogger" Version="3.0.114" PrivateAssets="All" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.1"/>
<PackageReference Include="BenchmarkDotNet.Annotations" Version="0.13.1"/>
<PackageReference Update="xunit" Version="2.9.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@
<ProjectReference Include="..\Elasticsearch.IntegrationDefaults\Elasticsearch.IntegrationDefaults.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="xunit" Version="2.9.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ namespace Elastic.Ingest.Elasticsearch.CommonSchema.IntegrationTests;

public class DataStreamIngestionTests : IntegrationTestBase
{
#pragma warning disable xUnit1041
public DataStreamIngestionTests(IngestionCluster cluster, ITestOutputHelper output) : base(cluster, output)
#pragma warning restore xUnit1041
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@
<ProjectReference Include="..\..\src\Elastic.Ingest.Elasticsearch.CommonSchema\Elastic.Ingest.Elasticsearch.CommonSchema.csproj" />
<ProjectReference Include="..\Elasticsearch.IntegrationDefaults\Elasticsearch.IntegrationDefaults.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="xunit" Version="2.9.3" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
<ProjectReference Include="..\Elasticsearch.IntegrationDefaults\Elasticsearch.IntegrationDefaults.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="xunit" Version="2.9.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<ItemGroup>
<PackageReference Include="Serilog.Sinks.ColoredConsole" Version="3.0.1" />
<PackageReference Update="xunit" Version="2.9.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ [I] public async Task AssertLogs()

var messages = search.Documents.Select(e => e.Message);
messages.Should().Contain("Hello Error");

search.Documents.First().Log.Should().NotBeNull();
search.Documents.First().Log!.Level.Should().NotBeNullOrEmpty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<ItemGroup>
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.16.2" />
<PackageReference Include="Elastic.Elasticsearch.Xunit" Version="0.5.0" />
<PackageReference Include="Elastic.Elasticsearch.Xunit" Version="0.6.0" />
<PackageReference Include="Elastic.Ingest.Elasticsearch" Version="0.10.0" />

</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\build\keys\keypair.snk</AssemblyOriginatorKeyFile>
<NoWarn>xUnit1041</NoWarn>
</PropertyGroup>
<ItemGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(ProjectName), '^(.*)Tests$'))">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<PackageReference Include="Moq" Version="4.12.0"/>
<PackageReference Include="Serilog.Sinks.XUnit" Version="3.0.3"/>
<PackageReference Include="Serilog.Sinks.InMemory" Version="0.5.0"/>
<PackageReference Update="xunit" Version="2.9.3" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions tests/Elastic.Apm.NLog.Tests/Elastic.Apm.NLog.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PackageReference Include="Moq" Version="4.12.0" />
<PackageReference Include="NLog" Version="4.7.15" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.5" />
<PackageReference Update="xunit" Version="2.9.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<ItemGroup>
<PackageReference Include="Moq" Version="4.12.0" />
<PackageReference Include="Serilog.Sinks.InMemory" Version="0.5.0" />
<PackageReference Update="xunit" Version="2.9.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@
<ProjectReference Include="..\Elastic.CommonSchema.Tests\Elastic.CommonSchema.Tests.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="xunit" Version="2.9.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PackageReference Include="NLog" Version="4.7.15" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.15.0" />
<PackageReference Include="Elastic.Apm" Version="1.22.0" />
<PackageReference Update="xunit" Version="2.9.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<PackageReference Include="Serilog.Sinks.TestCorrelator" Version="3.2.0" />
<PackageReference Include="Serilog.Sinks.XUnit" Version="2.0.4" />
<PackageReference Include="Elastic.Apm" Version="1.22.0" />
<PackageReference Update="xunit" Version="2.9.3" />
</ItemGroup>

<ItemGroup>
Expand Down
28 changes: 14 additions & 14 deletions tests/Elastic.CommonSchema.Tests/Elastic.CommonSchema.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Elastic.CommonSchema\Elastic.CommonSchema.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Elastic.CommonSchema\Elastic.CommonSchema.csproj"/>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Specs\spec.json" />
<None Include="Specs\spec_version.txt" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Specs\spec.json"/>
<None Include="Specs\spec_version.txt"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1"/>
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.2"/>
<PackageReference Update="xunit" Version="2.9.3" />
</ItemGroup>

</Project>
Loading