diff --git a/README.md b/README.md index f35ae30..096f513 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ Serilog logging for _Microsoft.Extensions.Hosting_. This package routes framewor **First**, install the _Serilog.Extensions.Hosting_ [NuGet package](https://www.nuget.org/packages/Serilog.Extensions.Hosting) into your app. You will need a way to view the log messages - _Serilog.Sinks.Console_ writes these to the console; there are [many more sinks available](https://www.nuget.org/packages?q=Tags%3A%22serilog%22) on NuGet. ```powershell -Install-Package Serilog.Extensions.Hosting -DependencyVersion Highest -Install-Package Serilog.Sinks.Console +dotnet add package Serilog.Extensions.Hosting +dotnet add package Serilog.Sinks.Console ``` **Next**, in your application's _Program.cs_ file, configure Serilog first. A `try`/`catch` block will ensure any configuration issues are appropriately logged: @@ -88,3 +88,7 @@ You can alternatively configure Serilog using a delegate as shown below: This has the advantage of making the `hostingContext`'s `Configuration` object available for configuration of the logger, but at the expense of ignoring `Exception`s raised earlier in program startup. If this method is used, `Log.Logger` is assigned implicitly, and closed when the app is shut down. + +### Versioning + +This package tracks the versioning and target framework support of its [_Microsoft.Extensions.Hosting_](https://nuget.org/packages/Microsoft.Extensions.Hosting) dependency. diff --git a/global.json b/global.json index af5a328..2c23bfe 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { "allowPrerelease": false, - "version": "6.0.300", + "version": "7.0.100", "rollForward": "latestFeature" } } diff --git a/samples/SimpleServiceSample/SimpleServiceSample.csproj b/samples/SimpleServiceSample/SimpleServiceSample.csproj index 9d323e4..c0736fa 100644 --- a/samples/SimpleServiceSample/SimpleServiceSample.csproj +++ b/samples/SimpleServiceSample/SimpleServiceSample.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net7.0 @@ -9,8 +9,8 @@ - - + + diff --git a/samples/WebApplicationSample/WebApplicationSample.csproj b/samples/WebApplicationSample/WebApplicationSample.csproj index 9f85c41..587f02c 100644 --- a/samples/WebApplicationSample/WebApplicationSample.csproj +++ b/samples/WebApplicationSample/WebApplicationSample.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net7.0 diff --git a/serilog-extensions-hosting.sln b/serilog-extensions-hosting.sln index 2208752..3b08c9f 100644 --- a/serilog-extensions-hosting.sln +++ b/serilog-extensions-hosting.sln @@ -26,6 +26,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleServiceSample", "samp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplicationSample", "samples\WebApplicationSample\WebApplicationSample.csproj", "{1ACDCA67-F404-45AB-9348-98E55E03CB8C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extensions.Logging", "..\serilog-extensions-logging\src\Serilog.Extensions.Logging\Serilog.Extensions.Logging.csproj", "{4369EFC6-EE7F-4CA1-B8C7-123C39B88708}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -48,6 +50,10 @@ Global {1ACDCA67-F404-45AB-9348-98E55E03CB8C}.Debug|Any CPU.Build.0 = Debug|Any CPU {1ACDCA67-F404-45AB-9348-98E55E03CB8C}.Release|Any CPU.ActiveCfg = Release|Any CPU {1ACDCA67-F404-45AB-9348-98E55E03CB8C}.Release|Any CPU.Build.0 = Release|Any CPU + {4369EFC6-EE7F-4CA1-B8C7-123C39B88708}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4369EFC6-EE7F-4CA1-B8C7-123C39B88708}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4369EFC6-EE7F-4CA1-B8C7-123C39B88708}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4369EFC6-EE7F-4CA1-B8C7-123C39B88708}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -57,6 +63,7 @@ Global {AD51759B-CD58-473F-9620-0B0E56A123A1} = {E30F638E-BBBE-4AD1-93CE-48CC69CFEFE1} {E5A82756-4619-4E6B-8B26-6D83E00E99F0} = {F2407211-6043-439C-8E06-3641634332E7} {1ACDCA67-F404-45AB-9348-98E55E03CB8C} = {F2407211-6043-439C-8E06-3641634332E7} + {4369EFC6-EE7F-4CA1-B8C7-123C39B88708} = {A1893BD1-333D-4DFE-A0F0-DDBB2FE526E0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {811E61C5-3871-4633-AFAE-B35B619C8A10} diff --git a/src/Serilog.Extensions.Hosting/Properties/AssemblyInfo.cs b/src/Serilog.Extensions.Hosting/Properties/AssemblyInfo.cs index 6890343..8ec980f 100644 --- a/src/Serilog.Extensions.Hosting/Properties/AssemblyInfo.cs +++ b/src/Serilog.Extensions.Hosting/Properties/AssemblyInfo.cs @@ -1,7 +1,7 @@ using System.Reflection; using System.Runtime.CompilerServices; -[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyVersion("7.0.0.0")] [assembly: InternalsVisibleTo("Serilog.Extensions.Hosting.Tests, PublicKey=" + "0024000004800000940000000602000000240000525341310004000001000100fb8d13fd344a1c" + diff --git a/src/Serilog.Extensions.Hosting/Serilog.Extensions.Hosting.csproj b/src/Serilog.Extensions.Hosting/Serilog.Extensions.Hosting.csproj index b95c5c2..dd5b4d4 100644 --- a/src/Serilog.Extensions.Hosting/Serilog.Extensions.Hosting.csproj +++ b/src/Serilog.Extensions.Hosting/Serilog.Extensions.Hosting.csproj @@ -2,17 +2,18 @@ Serilog support for .NET Core logging in hosted services - 5.1.0 + + 7.0.0 Microsoft;Serilog Contributors - netstandard2.0;netstandard2.1 + + net462;netstandard2.0;netstandard2.1;net6.0;net7.0 8 true true - Serilog.Extensions.Hosting ../../assets/Serilog.snk true true - Serilog.Extensions.Hosting serilog;aspnet;aspnetcore;hosting icon.png https://github.com/serilog/serilog-extensions-hosting @@ -23,20 +24,21 @@ Serilog - + $(DefineConstants);NO_RELOADABLE_LOGGER - - - - - + + + - - + + + + + diff --git a/test/Serilog.Extensions.Hosting.Tests/DiagnosticContextTests.cs b/test/Serilog.Extensions.Hosting.Tests/DiagnosticContextTests.cs index c3fbb1d..3281065 100644 --- a/test/Serilog.Extensions.Hosting.Tests/DiagnosticContextTests.cs +++ b/test/Serilog.Extensions.Hosting.Tests/DiagnosticContextTests.cs @@ -35,15 +35,16 @@ public async Task PropertiesAreCollectedInAnActiveContext() await Task.Delay(TimeSpan.FromMilliseconds(10)); dc.Set(Some.String("second"), Some.Int32()); - Assert.True(collector.TryComplete(out var properties)); + Assert.True(collector.TryComplete(out var properties, out var exception)); Assert.Equal(2, properties.Count()); + Assert.Null(exception); - Assert.False(collector.TryComplete(out _)); + Assert.False(collector.TryComplete(out _, out _)); collector.Dispose(); dc.Set(Some.String("third"), Some.Int32()); - Assert.False(collector.TryComplete(out _)); + Assert.False(collector.TryComplete(out _, out _)); } [Fact] @@ -97,10 +98,11 @@ public void ExistingPropertiesCanBeUpdated() dc.Set("name", 10); dc.Set("name", 20); - Assert.True(collector.TryComplete(out var properties)); + Assert.True(collector.TryComplete(out var properties, out var exception)); var prop = Assert.Single(properties); var scalar = Assert.IsType(prop.Value); Assert.Equal(20, scalar.Value); + Assert.Null(exception); } [Fact] diff --git a/test/Serilog.Extensions.Hosting.Tests/Serilog.Extensions.Hosting.Tests.csproj b/test/Serilog.Extensions.Hosting.Tests/Serilog.Extensions.Hosting.Tests.csproj index c964995..e83da0d 100644 --- a/test/Serilog.Extensions.Hosting.Tests/Serilog.Extensions.Hosting.Tests.csproj +++ b/test/Serilog.Extensions.Hosting.Tests/Serilog.Extensions.Hosting.Tests.csproj @@ -1,12 +1,10 @@  - netcoreapp3.1;net6.0;net4.8 - Serilog.Extensions.Hosting.Tests + net6.0;net7.0;net4.8 ../../assets/Serilog.snk true true - true latest @@ -19,13 +17,10 @@ - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + +