From b6abdac3527d3b7dfa075be929bdf2cb587d7faf Mon Sep 17 00:00:00 2001 From: Wilco Boshoff Date: Thu, 7 Feb 2019 15:30:26 +0200 Subject: [PATCH 1/2] Upgraded Microsoft.Extensions.Logging NuGet packages to 2.0.0 --- global.json | 2 +- .../Extensions/Logging/SerilogLoggerProvider.cs | 2 +- .../Serilog.Extensions.Logging.csproj | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/global.json b/global.json index 73bdd84..b3bc9e1 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.0.0-preview2-006497" + "version": "2.1.0" } } diff --git a/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerProvider.cs b/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerProvider.cs index 0a8910e..4af07f9 100644 --- a/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerProvider.cs +++ b/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerProvider.cs @@ -66,7 +66,7 @@ public IDisposable BeginScope(T state) // The outermost scope pushes and pops the Serilog `LogContext` - once // this enricher is on the stack, the `CurrentScope` property takes care // of the rest of the `BeginScope()` stack. - var popSerilogContext = LogContext.PushProperties(this); + var popSerilogContext = LogContext.Push(this); return new SerilogLoggerScope(this, state, popSerilogContext); } diff --git a/src/Serilog.Extensions.Logging/Serilog.Extensions.Logging.csproj b/src/Serilog.Extensions.Logging/Serilog.Extensions.Logging.csproj index d0adcc8..1607a12 100644 --- a/src/Serilog.Extensions.Logging/Serilog.Extensions.Logging.csproj +++ b/src/Serilog.Extensions.Logging/Serilog.Extensions.Logging.csproj @@ -23,17 +23,25 @@ - + - + + + + + + + + + $(DefineConstants);ASYNCLOCAL From 5c7ee2af886a1594db29f6744e1cf500ee065017 Mon Sep 17 00:00:00 2001 From: Wilco Boshoff Date: Fri, 8 Feb 2019 08:15:38 +0200 Subject: [PATCH 2/2] Removed all netcore1.3 references and dependent code. Assumed netcore2.0 dependency from here on out. --- build.sh | 1 - global.json | 2 +- .../Logging/SerilogLoggerProvider.cs | 22 ------------ .../Serilog.Extensions.Logging.csproj | 34 +++---------------- .../Serilog.Extensions.Logging.Tests.csproj | 6 ++-- 5 files changed, 7 insertions(+), 58 deletions(-) diff --git a/build.sh b/build.sh index dc51fc0..6d1ff38 100644 --- a/build.sh +++ b/build.sh @@ -3,7 +3,6 @@ dotnet --info dotnet restore for path in src/**/*.csproj; do - dotnet build -f netstandard1.3 -c Release ${path} dotnet build -f netstandard2.0 -c Release ${path} done diff --git a/global.json b/global.json index b3bc9e1..110af60 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.0" + "version": "2.0.0" } } diff --git a/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerProvider.cs b/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerProvider.cs index 4af07f9..2e9dbfe 100644 --- a/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerProvider.cs +++ b/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerProvider.cs @@ -2,12 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -#if ASYNCLOCAL using System.Threading; -#else -using System.Runtime.Remoting; -using System.Runtime.Remoting.Messaging; -#endif using Microsoft.Extensions.Logging; using Serilog.Core; using Serilog.Events; @@ -93,7 +88,6 @@ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) } } -#if ASYNCLOCAL readonly AsyncLocal _value = new AsyncLocal(); internal SerilogLoggerScope CurrentScope @@ -107,22 +101,6 @@ internal SerilogLoggerScope CurrentScope _value.Value = value; } } -#else - readonly string _currentScopeKey = nameof(SerilogLoggerScope) + "#" + Guid.NewGuid().ToString("n"); - - internal SerilogLoggerScope CurrentScope - { - get - { - var objectHandle = CallContext.LogicalGetData(_currentScopeKey) as ObjectHandle; - return objectHandle?.Unwrap() as SerilogLoggerScope; - } - set - { - CallContext.LogicalSetData(_currentScopeKey, new ObjectHandle(value)); - } - } -#endif /// public void Dispose() diff --git a/src/Serilog.Extensions.Logging/Serilog.Extensions.Logging.csproj b/src/Serilog.Extensions.Logging/Serilog.Extensions.Logging.csproj index 1607a12..0cc2562 100644 --- a/src/Serilog.Extensions.Logging/Serilog.Extensions.Logging.csproj +++ b/src/Serilog.Extensions.Logging/Serilog.Extensions.Logging.csproj @@ -4,7 +4,7 @@ Low-level Serilog provider for Microsoft.Extensions.Logging 2.0.1 Microsoft;Serilog Contributors - net45;net46;net461;netstandard1.3;netstandard2.0 + net461;netstandard2.0 true true Serilog.Extensions.Logging @@ -24,38 +24,12 @@ - - - - - - - - - - - - - - - + - - $(DefineConstants);ASYNCLOCAL - - - - $(DefineConstants);ASYNCLOCAL;LOGGING_BUILDER - - - - $(DefineConstants);ASYNCLOCAL - - - - $(DefineConstants);ASYNCLOCAL;LOGGING_BUILDER + + $(DefineConstants);LOGGING_BUILDER diff --git a/test/Serilog.Extensions.Logging.Tests/Serilog.Extensions.Logging.Tests.csproj b/test/Serilog.Extensions.Logging.Tests/Serilog.Extensions.Logging.Tests.csproj index 54eee14..c3ea6fb 100644 --- a/test/Serilog.Extensions.Logging.Tests/Serilog.Extensions.Logging.Tests.csproj +++ b/test/Serilog.Extensions.Logging.Tests/Serilog.Extensions.Logging.Tests.csproj @@ -1,15 +1,13 @@  - netcoreapp1.1;netcoreapp2.0;net46;net461 + netcoreapp2.0;net461 Serilog.Extensions.Logging.Tests ../../assets/Serilog.snk true true Serilog.Extensions.Logging.Tests true - $(PackageTargetFallback);dnxcore50;portable-net45+win8 - 1.0.4 @@ -22,7 +20,7 @@ - +