Skip to content

Commit 2eaf4ac

Browse files
authored
Fix serialization of Serilog.Sinks not including log.level (#511)
1 parent 7bdef4e commit 2eaf4ac

File tree

25 files changed

+55
-23
lines changed

25 files changed

+55
-23
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ resharper_csharp_accessor_owner_body=expression_body
207207

208208
resharper_redundant_case_label_highlighting=do_not_show
209209
resharper_redundant_argument_default_value_highlighting=do_not_show
210+
dotnet_diagnostic.xUnit1041.severity = none
210211

211212
[*.{sh,bat,ps1}]
212213
trim_trailing_whitespace=true

examples/Elastic.Extensions.Logging.Example/Elastic.Extensions.Logging.Example.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.0" />
12-
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.4.3" />
12+
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.6.0" />
1313
<PackageReference Include="NEST" Version="7.8.1" />
1414
</ItemGroup>
1515

examples/Elastic.Serilog.Sinks.Example/Elastic.Serilog.Sinks.Example.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageReference Include="Elastic.Apm" Version="1.22.0" />
1212
<PackageReference Include="Serilog" Version="4.1.0" />
1313
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
14-
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.4.3" />
14+
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.6.0" />
1515
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="9.0.4" />
1616
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
1717
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />

examples/aspnetcore-with-extensions-logging/aspnetcore-with-extensions-logging.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.4.3" />
11+
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.6.0" />
1212
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="9.0.4" />
1313
</ItemGroup>
1414

examples/playground/playground.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.5.0" />
15+
<PackageReference Include="Elastic.Elasticsearch.Ephemeral" Version="0.6.0" />
1616
</ItemGroup>
1717

1818
</Project>

src/Elastic.CommonSchema.Serilog/LogEventConverter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
using System.Diagnostics.CodeAnalysis;
88
using System.Linq;
99
using System.Text.Json.Serialization;
10+
using Elastic.CommonSchema.Serialization;
1011
using Serilog.Events;
1112
using static Elastic.CommonSchema.Serilog.SpecialProperties;
1213

1314
namespace Elastic.CommonSchema.Serilog
1415
{
1516
/// A specialized instance of <see cref="EcsDocument"/> that holds on to the original <see cref="LogEvent"/>
1617
/// <para> This property won't be emitted to JSON but is used to report back to serilog failure pipelines</para>
18+
[JsonConverter(typeof(EcsDocumentJsonConverterFactory))]
1719
public class LogEventEcsDocument : EcsDocument
1820
{
1921
/// The original <see cref="LogEvent"/> for bookkeeping, not send over to Elasticsearch

src/Elastic.CommonSchema/Serialization/EcsDocumentJsonConverter.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,5 @@ private static void WriteTimestamp(Utf8JsonWriter writer, BaseFieldSet value, Js
102102
/// <summary> A JsonConverter for <see cref="EcsDocument"/> that supports the
103103
/// https://github.com/elastic/ecs-logging specification
104104
/// </summary>
105-
public class EcsDocumentJsonConverter : EcsDocumentJsonConverter<EcsDocument>
106-
{
107-
}
105+
public class EcsDocumentJsonConverter : EcsDocumentJsonConverter<EcsDocument>;
108106
}

tests-integration/Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

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

1415
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114" PrivateAssets="All" />

tests-integration/Elastic.CommonSchema.BenchmarkDotNetExporter.IntegrationTests/Elastic.CommonSchema.BenchmarkDotNetExporter.IntegrationTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ItemGroup>
1313
<PackageReference Include="BenchmarkDotNet" Version="0.13.1"/>
1414
<PackageReference Include="BenchmarkDotNet.Annotations" Version="0.13.1"/>
15+
<PackageReference Update="xunit" Version="2.9.3" />
1516
</ItemGroup>
1617

1718
<ItemGroup>

tests-integration/Elastic.Extensions.Logging.IntegrationTests/Elastic.Extensions.Logging.IntegrationTests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@
1010
<ProjectReference Include="..\Elasticsearch.IntegrationDefaults\Elasticsearch.IntegrationDefaults.csproj" />
1111
</ItemGroup>
1212

13+
<ItemGroup>
14+
<PackageReference Update="xunit" Version="2.9.3" />
15+
</ItemGroup>
16+
1317
</Project>

tests-integration/Elastic.Ingest.Elasticsearch.CommonSchema.IntegrationTests/DataStreamIngestionTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ namespace Elastic.Ingest.Elasticsearch.CommonSchema.IntegrationTests;
1717

1818
public class DataStreamIngestionTests : IntegrationTestBase
1919
{
20+
#pragma warning disable xUnit1041
2021
public DataStreamIngestionTests(IngestionCluster cluster, ITestOutputHelper output) : base(cluster, output)
22+
#pragma warning restore xUnit1041
2123
{
2224
}
2325

tests-integration/Elastic.Ingest.Elasticsearch.CommonSchema.IntegrationTests/Elastic.Ingest.Elasticsearch.CommonSchema.IntegrationTests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@
1313
<ProjectReference Include="..\..\src\Elastic.Ingest.Elasticsearch.CommonSchema\Elastic.Ingest.Elasticsearch.CommonSchema.csproj" />
1414
<ProjectReference Include="..\Elasticsearch.IntegrationDefaults\Elasticsearch.IntegrationDefaults.csproj" />
1515
</ItemGroup>
16+
17+
<ItemGroup>
18+
<PackageReference Update="xunit" Version="2.9.3" />
19+
</ItemGroup>
1620
</Project>

tests-integration/Elastic.NLog.Targets.IntegrationTests/Elastic.NLog.Targets.IntegrationTests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111
<ProjectReference Include="..\Elasticsearch.IntegrationDefaults\Elasticsearch.IntegrationDefaults.csproj" />
1212
</ItemGroup>
1313

14+
<ItemGroup>
15+
<PackageReference Update="xunit" Version="2.9.3" />
16+
</ItemGroup>
17+
1418
</Project>

tests-integration/Elastic.Serilog.Sinks.IntegrationTests/Elastic.Serilog.Sinks.IntegrationTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
<ItemGroup>
1111
<PackageReference Include="Serilog.Sinks.ColoredConsole" Version="3.0.1" />
12+
<PackageReference Update="xunit" Version="2.9.3" />
1213
</ItemGroup>
1314

1415
<ItemGroup>

tests-integration/Elastic.Serilog.Sinks.IntegrationTests/SerilogOutputTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ [I] public async Task AssertLogs()
7373

7474
var messages = search.Documents.Select(e => e.Message);
7575
messages.Should().Contain("Hello Error");
76+
77+
search.Documents.First().Log.Should().NotBeNull();
78+
search.Documents.First().Log!.Level.Should().NotBeNullOrEmpty();
7679
}
7780
}
7881
}

tests-integration/Elasticsearch.IntegrationDefaults/Elasticsearch.IntegrationDefaults.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<ItemGroup>
1212
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="9.0.4" />
13-
<PackageReference Include="Elastic.Elasticsearch.Xunit" Version="0.5.0" />
13+
<PackageReference Include="Elastic.Elasticsearch.Xunit" Version="0.6.0" />
1414
<PackageReference Include="Elastic.Ingest.Elasticsearch" Version="0.10.0" />
1515

1616
</ItemGroup>

tests/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

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

tests/Elastic.Apm.Disabled.Serilog.Tests/Elastic.Apm.Disabled.Serilog.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<PackageReference Include="Moq" Version="4.12.0"/>
1111
<PackageReference Include="Serilog.Sinks.XUnit" Version="3.0.3"/>
1212
<PackageReference Include="Serilog.Sinks.InMemory" Version="0.5.0"/>
13+
<PackageReference Update="xunit" Version="2.9.3" />
1314
</ItemGroup>
1415

1516
<ItemGroup>

tests/Elastic.Apm.NLog.Tests/Elastic.Apm.NLog.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<PackageReference Include="Moq" Version="4.12.0" />
1010
<PackageReference Include="NLog" Version="4.7.15" />
1111
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.5" />
12+
<PackageReference Update="xunit" Version="2.9.3" />
1213
</ItemGroup>
1314

1415
<ItemGroup>

tests/Elastic.Apm.SerilogEnricher.Tests/Elastic.Apm.SerilogEnricher.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<ItemGroup>
99
<PackageReference Include="Moq" Version="4.12.0" />
1010
<PackageReference Include="Serilog.Sinks.InMemory" Version="0.5.0" />
11+
<PackageReference Update="xunit" Version="2.9.3" />
1112
</ItemGroup>
1213

1314
<ItemGroup>

tests/Elastic.CommonSchema.Log4net.Tests/Elastic.CommonSchema.Log4net.Tests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@
1010
<ProjectReference Include="..\Elastic.CommonSchema.Tests\Elastic.CommonSchema.Tests.csproj" />
1111
</ItemGroup>
1212

13+
<ItemGroup>
14+
<PackageReference Update="xunit" Version="2.9.3" />
15+
</ItemGroup>
16+
1317
</Project>

tests/Elastic.CommonSchema.NLog.Tests/Elastic.CommonSchema.NLog.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<PackageReference Include="NLog" Version="4.7.15" />
1212
<PackageReference Include="NLog.Web.AspNetCore" Version="4.15.0" />
1313
<PackageReference Include="Elastic.Apm" Version="1.22.0" />
14+
<PackageReference Update="xunit" Version="2.9.3" />
1415
</ItemGroup>
1516

1617
<ItemGroup>

tests/Elastic.CommonSchema.Serilog.Tests/Elastic.CommonSchema.Serilog.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<PackageReference Include="Serilog.Sinks.TestCorrelator" Version="3.2.0" />
1919
<PackageReference Include="Serilog.Sinks.XUnit" Version="2.0.4" />
2020
<PackageReference Include="Elastic.Apm" Version="1.22.0" />
21+
<PackageReference Update="xunit" Version="2.9.3" />
2122
</ItemGroup>
2223

2324
<ItemGroup>
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFrameworks>net8.0</TargetFrameworks>
5-
<IsPackable>false</IsPackable>
6-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<IsPackable>false</IsPackable>
6+
</PropertyGroup>
77

8-
<ItemGroup>
9-
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
10-
</ItemGroup>
8+
<ItemGroup>
9+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
10+
</ItemGroup>
1111

12-
<ItemGroup>
13-
<ProjectReference Include="..\..\src\Elastic.CommonSchema\Elastic.CommonSchema.csproj" />
14-
</ItemGroup>
12+
<ItemGroup>
13+
<ProjectReference Include="..\..\src\Elastic.CommonSchema\Elastic.CommonSchema.csproj"/>
14+
</ItemGroup>
1515

16-
<ItemGroup>
17-
<EmbeddedResource Include="Specs\spec.json" />
18-
<None Include="Specs\spec_version.txt" />
19-
</ItemGroup>
16+
<ItemGroup>
17+
<EmbeddedResource Include="Specs\spec.json"/>
18+
<None Include="Specs\spec_version.txt"/>
19+
</ItemGroup>
2020

2121
</Project>

tests/Elastic.Serilog.Sinks.Tests/Elastic.Serilog.Sinks.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0"/>
1616
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1"/>
1717
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.2"/>
18+
<PackageReference Update="xunit" Version="2.9.3" />
1819
</ItemGroup>
1920

2021
</Project>

0 commit comments

Comments
 (0)