diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..acd3bc6
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,41 @@
+# If this file is renamed, the incrementing run attempt number will be reset.
+
+name: CI
+
+on:
+ push:
+ branches: [ "dev", "main" ]
+ pull_request:
+ branches: [ "dev", "main" ]
+
+env:
+ CI_BUILD_NUMBER_BASE: ${{ github.run_number }}
+ CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }}
+
+jobs:
+ build:
+
+ # The build must run on Windows so that .NET Framework targets can be built and tested.
+ runs-on: windows-latest
+
+ permissions:
+ contents: write
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: Setup
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: 9.0.x
+ - name: Compute build number
+ shell: bash
+ run: |
+ echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+2300))" >> $GITHUB_ENV
+ - name: Build and Publish
+ env:
+ DOTNET_CLI_TELEMETRY_OPTOUT: true
+ NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ shell: pwsh
+ run: |
+ ./Build.ps1
diff --git a/.gitignore b/.gitignore
index 0173fad..4b9f99e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -286,3 +286,6 @@ __pycache__/
*.odx.cs
*.xsd.cs
/samples/WebApplicationSample/logs/
+
+.DS_Store
+
diff --git a/Build.ps1 b/Build.ps1
index cce9432..e798284 100644
--- a/Build.ps1
+++ b/Build.ps1
@@ -1,56 +1,79 @@
-echo "build: Build started"
+Write-Output "build: Tool versions follow"
+
+dotnet --version
+dotnet --list-sdks
+
+Write-Output "build: Build started"
Push-Location $PSScriptRoot
+try {
+ if(Test-Path .\artifacts) {
+ Write-Output "build: Cleaning ./artifacts"
+ Remove-Item ./artifacts -Force -Recurse
+ }
-if(Test-Path .\artifacts) {
- echo "build: Cleaning .\artifacts"
- Remove-Item .\artifacts -Force -Recurse
-}
+ & dotnet restore --no-cache
+
+ $dbp = [Xml] (Get-Content .\Directory.Version.props)
+ $versionPrefix = $dbp.Project.PropertyGroup.VersionPrefix
+
+ Write-Output "build: Package version prefix is $versionPrefix"
+
+ $branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH];
+ $revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER];
+ $suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "main" -and $revision -ne "local"]
+ $commitHash = $(git rev-parse --short HEAD)
+ $buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
-& dotnet restore --no-cache
+ Write-Output "build: Package version suffix is $suffix"
+ Write-Output "build: Build version suffix is $buildSuffix"
-$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
-$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
-$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"]
+ & dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true
+ if($LASTEXITCODE -ne 0) { throw "Build failed" }
-echo "build: Version suffix is $suffix"
+ foreach ($src in Get-ChildItem src/*) {
+ Push-Location $src
-foreach ($src in ls src/*) {
- Push-Location $src
+ Write-Output "build: Packaging project in $src"
- echo "build: Packaging project in $src"
+ if ($suffix) {
+ & dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix
+ } else {
+ & dotnet pack -c Release --no-build --no-restore -o ../../artifacts
+ }
+ if($LASTEXITCODE -ne 0) { throw "Packaging failed" }
- if($suffix) {
- & dotnet pack -c Release --include-source -o ..\..\artifacts --version-suffix=$suffix
- } else {
- & dotnet pack -c Release --include-source -o ..\..\artifacts
+ Pop-Location
}
-
- if($LASTEXITCODE -ne 0) { exit 1 }
- Pop-Location
-}
+ foreach ($test in Get-ChildItem test/*.Tests) {
+ Push-Location $test
-foreach ($test in ls test/*.PerformanceTests) {
- Push-Location $test
+ Write-Output "build: Testing project in $test"
- echo "build: Building performance test project in $test"
+ & dotnet test -c Release --no-build --no-restore
+ if($LASTEXITCODE -ne 0) { throw "Testing failed" }
- & dotnet build -c Release
- if($LASTEXITCODE -ne 0) { exit 2 }
+ Pop-Location
+ }
- Pop-Location
-}
+ if ($env:NUGET_API_KEY) {
+ # GitHub Actions will only supply this to branch builds and not PRs. We publish
+ # builds from any branch this action targets (i.e. main and dev).
-foreach ($test in ls test/*.Tests) {
- Push-Location $test
+ Write-Output "build: Publishing NuGet packages"
- echo "build: Testing project in $test"
+ foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) {
+ & dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg"
+ if($LASTEXITCODE -ne 0) { throw "Publishing failed" }
+ }
- & dotnet test -c Release
- if($LASTEXITCODE -ne 0) { exit 3 }
+ if (!($suffix)) {
+ Write-Output "build: Creating release for version $versionPrefix"
+ iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)"
+ }
+ }
+} finally {
Pop-Location
}
-
-Pop-Location
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 0000000..c114992
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,25 @@
+
+
+
+
+ latest
+ True
+
+ true
+ $(MSBuildThisFileDirectory)assets/Serilog.snk
+ false
+ enable
+ enable
+ true
+ true
+ true
+ true
+ snupkg
+
+
+
+
+
+
+
diff --git a/Directory.Version.props b/Directory.Version.props
new file mode 100644
index 0000000..c8c7b22
--- /dev/null
+++ b/Directory.Version.props
@@ -0,0 +1,6 @@
+
+
+
+ 9.0.0
+
+
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index f52401f..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-version: '{build}'
-skip_tags: true
-image: Visual Studio 2022
-test: off
-build_script:
-- pwsh: |
- Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./dotnet-install.ps1"
- ./dotnet-install.ps1 -JSonFile global.json -Architecture x64 -InstallDir 'C:\Program Files\dotnet'
- ./Build.ps1
-artifacts:
-- path: artifacts/Serilog.*.nupkg
-skip_commits:
- files:
- - README.md
-deploy:
-- provider: NuGet
- skip_symbols: true
- api_key:
- secure: H96ajkMxwIafhF2vrr+UAUS10bFcAL/1wc3iphidRiYi9WoTc2i8shTLtF+75ODb
- on:
- branch: /^(main|dev)$/
-- provider: GitHub
- auth_token:
- secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
- artifact: /Serilog.*\.nupkg/
- tag: v$(appveyor_build_version)
- on:
- branch: main
diff --git a/build.sh b/build.sh
deleted file mode 100644
index 433a9b4..0000000
--- a/build.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-dotnet --info
-dotnet restore
-
-for path in src/**/*.csproj; do
- dotnet build -f netstandard2.0 -c Release ${path}
-done
-
-for path in test/*.Tests/*.csproj; do
- dotnet test -f netcoreapp2.0 -c Release ${path}
-done
diff --git a/global.json b/global.json
index d079f83..db8627a 100644
--- a/global.json
+++ b/global.json
@@ -1,7 +1,7 @@
{
"sdk": {
+ "version": "9.0.100",
"allowPrerelease": false,
- "version": "8.0.100",
"rollForward": "latestFeature"
}
}
diff --git a/samples/SimpleServiceSample/SimpleServiceSample.csproj b/samples/SimpleServiceSample/SimpleServiceSample.csproj
index 3451be2..9890c70 100644
--- a/samples/SimpleServiceSample/SimpleServiceSample.csproj
+++ b/samples/SimpleServiceSample/SimpleServiceSample.csproj
@@ -1,7 +1,8 @@
- net8.0
+ net9.0
+ false
@@ -9,9 +10,9 @@
-
-
-
+
+
+
diff --git a/samples/WebApplicationSample/WebApplicationSample.csproj b/samples/WebApplicationSample/WebApplicationSample.csproj
index 8fbe382..ff0965f 100644
--- a/samples/WebApplicationSample/WebApplicationSample.csproj
+++ b/samples/WebApplicationSample/WebApplicationSample.csproj
@@ -1,7 +1,8 @@
- net8.0
+ net9.0
+ false
@@ -9,9 +10,9 @@
-
-
-
+
+
+
diff --git a/serilog-extensions-hosting.sln b/serilog-extensions-hosting.sln
index 2208752..37c65ef 100644
--- a/serilog-extensions-hosting.sln
+++ b/serilog-extensions-hosting.sln
@@ -11,11 +11,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{F240
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{9C21B9DF-AEDD-4AA6-BEA4-912DEF3E5B8E}"
ProjectSection(SolutionItems) = preProject
- appveyor.yml = appveyor.yml
- Build.ps1 = Build.ps1
- global.json = global.json
README.md = README.md
assets\Serilog.snk = assets\Serilog.snk
+ Build.ps1 = Build.ps1
+ global.json = global.json
+ Directory.Version.props = Directory.Version.props
+ Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Extensions.Hosting", "src\Serilog.Extensions.Hosting\Serilog.Extensions.Hosting.csproj", "{0549D23F-986B-4FB2-BACE-16FD7A7BC9EF}"
@@ -26,6 +27,13 @@ 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("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{5C68E1CE-D650-4500-B32C-21EDD0AAA0A7}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{10168223-6AEF-4B08-B6FD-50C6FD3B6E84}"
+ ProjectSection(SolutionItems) = preProject
+ .github\workflows\ci.yml = .github\workflows\ci.yml
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -57,6 +65,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}
+ {10168223-6AEF-4B08-B6FD-50C6FD3B6E84} = {5C68E1CE-D650-4500-B32C-21EDD0AAA0A7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {811E61C5-3871-4633-AFAE-B35B619C8A10}
diff --git a/src/Serilog.Extensions.Hosting/Extensions/Hosting/AmbientDiagnosticContextCollector.cs b/src/Serilog.Extensions.Hosting/Extensions/Hosting/AmbientDiagnosticContextCollector.cs
index 02eb1c9..a96545a 100644
--- a/src/Serilog.Extensions.Hosting/Extensions/Hosting/AmbientDiagnosticContextCollector.cs
+++ b/src/Serilog.Extensions.Hosting/Extensions/Hosting/AmbientDiagnosticContextCollector.cs
@@ -12,21 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using System;
-using System.Threading;
-
namespace Serilog.Extensions.Hosting;
class AmbientDiagnosticContextCollector : IDisposable
{
- static readonly AsyncLocal AmbientCollector =
- new AsyncLocal();
+ static readonly AsyncLocal AmbientCollector = new();
// The indirection here ensures that completing collection cleans up the collector in all
// execution contexts. Via @benaadams' addition to `HttpContextAccessor` :-)
- DiagnosticContextCollector _collector;
+ DiagnosticContextCollector? _collector;
- public static DiagnosticContextCollector Current => AmbientCollector.Value?._collector;
+ public static DiagnosticContextCollector? Current => AmbientCollector.Value?._collector;
public static DiagnosticContextCollector Begin()
{
diff --git a/src/Serilog.Extensions.Hosting/Extensions/Hosting/CachingReloadableLogger.cs b/src/Serilog.Extensions.Hosting/Extensions/Hosting/CachingReloadableLogger.cs
index 7f235e5..3b9d058 100644
--- a/src/Serilog.Extensions.Hosting/Extensions/Hosting/CachingReloadableLogger.cs
+++ b/src/Serilog.Extensions.Hosting/Extensions/Hosting/CachingReloadableLogger.cs
@@ -12,23 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#if !NO_RELOADABLE_LOGGER
-
-using System;
-using System.Collections.Generic;
-using System.Threading;
+using System.Diagnostics.CodeAnalysis;
using Serilog.Core;
using Serilog.Events;
namespace Serilog.Extensions.Hosting;
-class CachingReloadableLogger : ILogger, IReloadableLogger
+class CachingReloadableLogger : LoggerBase, ILogger, IReloadableLogger
{
readonly ReloadableLogger _reloadableLogger;
readonly Func _configure;
readonly IReloadableLogger _parent;
-
- ILogger _root, _cached;
+
+ ILogger _root;
+ ILogger? _cached;
bool _frozen;
public CachingReloadableLogger(ReloadableLogger reloadableLogger, ILogger root, IReloadableLogger parent, Func configure)
@@ -48,10 +45,10 @@ public ILogger ReloadLogger()
public ILogger ForContext(ILogEventEnricher enricher)
{
- if (enricher == null) return this;
+ if (enricher == null!) return this;
if (_frozen)
- return _cached.ForContext(enricher);
+ return _cached!.ForContext(enricher);
if (_reloadableLogger.CreateChild(
_root,
@@ -71,10 +68,10 @@ public ILogger ForContext(ILogEventEnricher enricher)
public ILogger ForContext(IEnumerable enrichers)
{
- if (enrichers == null) return this;
+ if (enrichers == null!) return this;
if (_frozen)
- return _cached.ForContext(enrichers);
+ return _cached!.ForContext(enrichers);
if (_reloadableLogger.CreateChild(
_root,
@@ -92,12 +89,12 @@ public ILogger ForContext(IEnumerable enrichers)
return child;
}
- public ILogger ForContext(string propertyName, object value, bool destructureObjects = false)
+ public ILogger ForContext(string propertyName, object? value, bool destructureObjects = false)
{
- if (propertyName == null) return this;
+ if (propertyName == null!) return this;
if (_frozen)
- return _cached.ForContext(propertyName, value, destructureObjects);
+ return _cached!.ForContext(propertyName, value, destructureObjects);
ILogger child;
if (value == null || value is string || value.GetType().IsPrimitive || value.GetType().IsEnum)
@@ -147,7 +144,7 @@ public ILogger ForContext(string propertyName, object value, bool destructureObj
public ILogger ForContext()
{
if (_frozen)
- return _cached.ForContext();
+ return _cached!.ForContext();
if (_reloadableLogger.CreateChild(
_root,
@@ -168,7 +165,7 @@ public ILogger ForContext()
public ILogger ForContext(Type source)
{
if (_frozen)
- return _cached.ForContext(source);
+ return _cached!.ForContext(source);
if (_reloadableLogger.CreateChild(
_root,
@@ -186,7 +183,7 @@ public ILogger ForContext(Type source)
return child;
}
- void Update(ILogger newRoot, ILogger newCached, bool frozen)
+ void Update(ILogger newRoot, ILogger? newCached, bool frozen)
{
_root = newRoot;
_cached = newCached;
@@ -194,18 +191,25 @@ void Update(ILogger newRoot, ILogger newCached, bool frozen)
// https://github.com/dotnet/runtime/issues/20500#issuecomment-284774431
// Publish `_cached` and then `_frozen`. This is useful here because it means that once the logger is frozen - which
// we always expect - reads don't require any synchronization/interlocked instructions.
+#if FEATURE_MBPW
Interlocked.MemoryBarrierProcessWide();
-
+#else
+ Thread.MemoryBarrier();
+#endif
_frozen = frozen;
+#if FEATURE_MBPW
Interlocked.MemoryBarrierProcessWide();
+#else
+ Thread.MemoryBarrier();
+#endif
}
- public void Write(LogEvent logEvent)
+ public override void Write(LogEvent logEvent)
{
if (_frozen)
{
- _cached.Write(logEvent);
+ _cached!.Write(logEvent);
return;
}
@@ -222,11 +226,11 @@ public void Write(LogEvent logEvent)
}
}
- public void Write(LogEventLevel level, string messageTemplate)
+ public override void Write(LogEventLevel level, string messageTemplate)
{
if (_frozen)
{
- _cached.Write(level, messageTemplate);
+ _cached!.Write(level, messageTemplate);
return;
}
@@ -244,11 +248,11 @@ public void Write(LogEventLevel level, string messageTemplate)
}
}
- public void Write(LogEventLevel level, string messageTemplate, T propertyValue)
+ public override void Write(LogEventLevel level, string messageTemplate, T propertyValue)
{
if (_frozen)
{
- _cached.Write(level, messageTemplate, propertyValue);
+ _cached!.Write(level, messageTemplate, propertyValue);
return;
}
@@ -267,11 +271,11 @@ public void Write(LogEventLevel level, string messageTemplate, T propertyValu
}
}
- public void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ public override void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
{
if (_frozen)
{
- _cached.Write(level, messageTemplate, propertyValue0, propertyValue1);
+ _cached!.Write(level, messageTemplate, propertyValue0, propertyValue1);
return;
}
@@ -291,12 +295,12 @@ public void Write(LogEventLevel level, string messageTemplate, T0 proper
}
}
- public void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1,
+ public override void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1,
T2 propertyValue2)
{
if (_frozen)
{
- _cached.Write(level, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
+ _cached!.Write(level, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
return;
}
@@ -317,11 +321,11 @@ public void Write(LogEventLevel level, string messageTemplate, T0 pr
}
}
- public void Write(LogEventLevel level, string messageTemplate, params object[] propertyValues)
+ public override void Write(LogEventLevel level, string messageTemplate, params object?[]? propertyValues)
{
if (_frozen)
{
- _cached.Write(level, messageTemplate, propertyValues);
+ _cached!.Write(level, messageTemplate, propertyValues);
return;
}
@@ -340,11 +344,11 @@ public void Write(LogEventLevel level, string messageTemplate, params object[] p
}
}
- public void Write(LogEventLevel level, Exception exception, string messageTemplate)
+ public override void Write(LogEventLevel level, Exception? exception, string messageTemplate)
{
if (_frozen)
{
- _cached.Write(level, exception, messageTemplate);
+ _cached!.Write(level, exception, messageTemplate);
return;
}
@@ -363,11 +367,11 @@ public void Write(LogEventLevel level, Exception exception, string messageTempla
}
}
- public void Write(LogEventLevel level, Exception exception, string messageTemplate, T propertyValue)
+ public override void Write(LogEventLevel level, Exception? exception, string messageTemplate, T propertyValue)
{
if (_frozen)
{
- _cached.Write(level, exception, messageTemplate, propertyValue);
+ _cached!.Write(level, exception, messageTemplate, propertyValue);
return;
}
@@ -387,12 +391,12 @@ public void Write(LogEventLevel level, Exception exception, string messageTem
}
}
- public void Write(LogEventLevel level, Exception exception, string messageTemplate, T0 propertyValue0,
+ public override void Write(LogEventLevel level, Exception? exception, string messageTemplate, T0 propertyValue0,
T1 propertyValue1)
{
if (_frozen)
{
- _cached.Write(level, exception, messageTemplate, propertyValue0, propertyValue1);
+ _cached!.Write(level, exception, messageTemplate, propertyValue0, propertyValue1);
return;
}
@@ -413,12 +417,12 @@ public void Write(LogEventLevel level, Exception exception, string messa
}
}
- public void Write(LogEventLevel level, Exception exception, string messageTemplate, T0 propertyValue0,
+ public override void Write(LogEventLevel level, Exception? exception, string messageTemplate, T0 propertyValue0,
T1 propertyValue1, T2 propertyValue2)
{
if (_frozen)
{
- _cached.Write(level, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
+ _cached!.Write(level, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
return;
}
@@ -440,11 +444,11 @@ public void Write(LogEventLevel level, Exception exception, string m
}
}
- public void Write(LogEventLevel level, Exception exception, string messageTemplate, params object[] propertyValues)
+ public override void Write(LogEventLevel level, Exception? exception, string messageTemplate, params object?[]? propertyValues)
{
if (_frozen)
{
- _cached.Write(level, exception, messageTemplate, propertyValues);
+ _cached!.Write(level, exception, messageTemplate, propertyValues);
return;
}
@@ -468,7 +472,7 @@ public bool IsEnabled(LogEventLevel level)
{
if (_frozen)
{
- return _cached.IsEnabled(level);
+ return _cached!.IsEnabled(level);
}
if (_reloadableLogger.InvokeIsEnabled(
@@ -487,12 +491,15 @@ public bool IsEnabled(LogEventLevel level)
return isEnabled;
}
- public bool BindMessageTemplate(string messageTemplate, object[] propertyValues, out MessageTemplate parsedTemplate,
- out IEnumerable boundProperties)
+ public bool BindMessageTemplate(string messageTemplate, object?[]? propertyValues,
+ [NotNullWhen(true)]
+ out MessageTemplate? parsedTemplate,
+ [NotNullWhen(true)]
+ out IEnumerable? boundProperties)
{
if (_frozen)
{
- return _cached.BindMessageTemplate(messageTemplate, propertyValues, out parsedTemplate, out boundProperties);
+ return _cached!.BindMessageTemplate(messageTemplate, propertyValues, out parsedTemplate, out boundProperties);
}
if (_reloadableLogger.InvokeBindMessageTemplate(
@@ -514,11 +521,13 @@ public bool BindMessageTemplate(string messageTemplate, object[] propertyValues,
return canBind;
}
- public bool BindProperty(string propertyName, object value, bool destructureObjects, out LogEventProperty property)
+ public bool BindProperty(string? propertyName, object? value, bool destructureObjects,
+ [NotNullWhen(true)]
+ out LogEventProperty? property)
{
if (_frozen)
{
- return _cached.BindProperty(propertyName, value, destructureObjects, out property);
+ return _cached!.BindProperty(propertyName, value, destructureObjects, out property);
}
if (_reloadableLogger.InvokeBindProperty(
@@ -540,5 +549,3 @@ public bool BindProperty(string propertyName, object value, bool destructureObje
return canBind;
}
}
-
-#endif
diff --git a/src/Serilog.Extensions.Hosting/Extensions/Hosting/DiagnosticContext.cs b/src/Serilog.Extensions.Hosting/Extensions/Hosting/DiagnosticContext.cs
index 7f4ee2b..62fce9f 100644
--- a/src/Serilog.Extensions.Hosting/Extensions/Hosting/DiagnosticContext.cs
+++ b/src/Serilog.Extensions.Hosting/Extensions/Hosting/DiagnosticContext.cs
@@ -23,13 +23,13 @@ namespace Serilog.Extensions.Hosting;
/// Consumers should use to set context properties.
public sealed class DiagnosticContext : IDiagnosticContext
{
- readonly ILogger _logger;
+ readonly ILogger? _logger;
///
/// Construct a .
///
/// A logger for binding properties in the context, or null to use .
- public DiagnosticContext(ILogger logger)
+ public DiagnosticContext(ILogger? logger)
{
_logger = logger;
}
diff --git a/src/Serilog.Extensions.Hosting/Extensions/Hosting/DiagnosticContextCollector.cs b/src/Serilog.Extensions.Hosting/Extensions/Hosting/DiagnosticContextCollector.cs
index 05734f6..6ade4ff 100644
--- a/src/Serilog.Extensions.Hosting/Extensions/Hosting/DiagnosticContextCollector.cs
+++ b/src/Serilog.Extensions.Hosting/Extensions/Hosting/DiagnosticContextCollector.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using Serilog.Events;
+using Serilog.Events;
namespace Serilog.Extensions.Hosting;
@@ -10,9 +8,9 @@ namespace Serilog.Extensions.Hosting;
public sealed class DiagnosticContextCollector : IDisposable
{
readonly IDisposable _chainedDisposable;
- readonly object _propertiesLock = new object();
- Exception _exception;
- Dictionary _properties = new Dictionary();
+ readonly object _propertiesLock = new();
+ Exception? _exception;
+ Dictionary? _properties = new();
///
/// Construct a .
@@ -70,7 +68,7 @@ public void SetException(Exception exception)
/// True if properties could be collected.
///
[Obsolete("Replaced by TryComplete(out IEnumerable properties, out Exception exception).")]
- public bool TryComplete(out IEnumerable properties)
+ public bool TryComplete(out IEnumerable? properties)
{
return TryComplete(out properties, out _);
}
@@ -85,7 +83,7 @@ public bool TryComplete(out IEnumerable properties)
/// True if properties could be collected.
///
///
- public bool TryComplete(out IEnumerable properties, out Exception exception)
+ public bool TryComplete(out IEnumerable? properties, out Exception? exception)
{
lock (_propertiesLock)
{
diff --git a/src/Serilog.Extensions.Hosting/Extensions/Hosting/LoggerBase.cs b/src/Serilog.Extensions.Hosting/Extensions/Hosting/LoggerBase.cs
new file mode 100644
index 0000000..c52256b
--- /dev/null
+++ b/src/Serilog.Extensions.Hosting/Extensions/Hosting/LoggerBase.cs
@@ -0,0 +1,918 @@
+// Copyright 2020 Serilog Contributors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// 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 the License for the specific language governing permissions and
+// limitations under the License.
+
+using Serilog.Core;
+using Serilog.Events;
+
+namespace Serilog.Extensions.Hosting;
+
+///
+/// Implements default methods for caching/reloadable loggers.
+///
+public abstract class LoggerBase
+{
+ static readonly object[] NoPropertyValues = [];
+
+ internal LoggerBase()
+ {
+ }
+
+ ///
+ /// Write an event to the log.
+ ///
+ /// The event to write.
+ public abstract void Write(LogEvent logEvent);
+
+ ///
+ /// Write a log event with the specified level.
+ ///
+ /// The level of the event.
+ /// Message template describing the event.
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public abstract void Write(LogEventLevel level, string messageTemplate);
+
+ ///
+ /// Write a log event with the specified level.
+ ///
+ /// The level of the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public abstract void Write(LogEventLevel level, string messageTemplate, T propertyValue);
+
+ ///
+ /// Write a log event with the specified level.
+ ///
+ /// The level of the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public abstract void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1);
+
+ ///
+ /// Write a log event with the specified level.
+ ///
+ /// The level of the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public abstract void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1,
+ T2 propertyValue2);
+
+ ///
+ /// Write a log event with the specified level.
+ ///
+ /// The level of the event.
+ ///
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public abstract void Write(LogEventLevel level, string messageTemplate, params object?[]? propertyValues);
+
+ ///
+ /// Write a log event with the specified level and associated exception.
+ ///
+ /// The level of the event.
+ /// Exception related to the event.
+ /// Message template describing the event.
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public abstract void Write(LogEventLevel level, Exception? exception, string messageTemplate);
+
+ ///
+ /// Write a log event with the specified level and associated exception.
+ ///
+ /// The level of the event.
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public abstract void Write(LogEventLevel level, Exception? exception, string messageTemplate, T propertyValue);
+
+ ///
+ /// Write a log event with the specified level and associated exception.
+ ///
+ /// The level of the event.
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public abstract void Write(LogEventLevel level, Exception? exception, string messageTemplate, T0 propertyValue0,
+ T1 propertyValue1);
+
+ ///
+ /// Write a log event with the specified level and associated exception.
+ ///
+ /// The level of the event.
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public abstract void Write(LogEventLevel level, Exception? exception, string messageTemplate,
+ T0 propertyValue0, T1 propertyValue1, T2 propertyValue2);
+
+ ///
+ /// Write a log event with the specified level and associated exception.
+ ///
+ /// The level of the event.
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Objects positionally formatted into the message template.
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public abstract void Write(LogEventLevel level, Exception? exception, string messageTemplate, params object?[]? propertyValues);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ ///
+ /// Log.Verbose("Staring into space, wondering if we're alone.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Verbose(string messageTemplate)
+ => Write(LogEventLevel.Verbose, messageTemplate, NoPropertyValues);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Verbose("Staring into space, wondering if we're alone.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Verbose(string messageTemplate, T propertyValue)
+ => Write(LogEventLevel.Verbose, messageTemplate, propertyValue);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Verbose("Staring into space, wondering if we're alone.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Verbose(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ => Write(LogEventLevel.Verbose, messageTemplate, propertyValue0, propertyValue1);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Verbose("Staring into space, wondering if we're alone.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Verbose(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
+ => Write(LogEventLevel.Verbose, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Message template describing the event.
+ /// Objects positionally formatted into the message template.
+ ///
+ /// Log.Verbose("Staring into space, wondering if we're alone.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Verbose(string messageTemplate, params object?[]? propertyValues)
+ => Verbose((Exception?)null, messageTemplate, propertyValues);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ ///
+ /// Log.Verbose(ex, "Staring into space, wondering where this comet came from.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Verbose(Exception? exception, string messageTemplate)
+ => Write(LogEventLevel.Verbose, exception, messageTemplate, NoPropertyValues);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Verbose(ex, "Staring into space, wondering where this comet came from.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Verbose(Exception? exception, string messageTemplate, T propertyValue)
+ => Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValue);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Verbose(ex, "Staring into space, wondering where this comet came from.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Verbose(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ => Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValue0, propertyValue1);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Verbose(ex, "Staring into space, wondering where this comet came from.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Verbose(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1,
+ T2 propertyValue2)
+ => Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Objects positionally formatted into the message template.
+ ///
+ /// Log.Verbose(ex, "Staring into space, wondering where this comet came from.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Verbose(Exception? exception, string messageTemplate, params object?[]? propertyValues)
+ => Write(LogEventLevel.Verbose, exception, messageTemplate, propertyValues);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ ///
+ /// Log.Debug("Starting up at {StartedAt}.", DateTime.Now);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Debug(string messageTemplate)
+ => Write(LogEventLevel.Debug, messageTemplate, NoPropertyValues);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Debug("Starting up at {StartedAt}.", DateTime.Now);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Debug(string messageTemplate, T propertyValue)
+ => Write(LogEventLevel.Debug, messageTemplate, propertyValue);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Debug("Starting up at {StartedAt}.", DateTime.Now);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Debug(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ => Write(LogEventLevel.Debug, messageTemplate, propertyValue0, propertyValue1);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Debug("Starting up at {StartedAt}.", DateTime.Now);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Debug(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
+ => Write(LogEventLevel.Debug, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Message template describing the event.
+ /// Objects positionally formatted into the message template.
+ ///
+ /// Log.Debug("Starting up at {StartedAt}.", DateTime.Now);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Debug(string messageTemplate, params object?[]? propertyValues)
+ => Debug((Exception?)null, messageTemplate, propertyValues);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ ///
+ /// Log.Debug(ex, "Swallowing a mundane exception.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Debug(Exception? exception, string messageTemplate)
+ => Write(LogEventLevel.Debug, exception, messageTemplate, NoPropertyValues);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Debug(ex, "Swallowing a mundane exception.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Debug(Exception? exception, string messageTemplate, T propertyValue)
+ => Write(LogEventLevel.Debug, exception, messageTemplate, propertyValue);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Debug(ex, "Swallowing a mundane exception.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Debug(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ => Write(LogEventLevel.Debug, exception, messageTemplate, propertyValue0, propertyValue1);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Debug(ex, "Swallowing a mundane exception.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Debug(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1,
+ T2 propertyValue2)
+ => Write(LogEventLevel.Debug, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Objects positionally formatted into the message template.
+ ///
+ /// Log.Debug(ex, "Swallowing a mundane exception.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Debug(Exception? exception, string messageTemplate, params object?[]? propertyValues)
+ => Write(LogEventLevel.Debug, exception, messageTemplate, propertyValues);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ ///
+ /// Log.Information("Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Information(string messageTemplate)
+ => Write(LogEventLevel.Information, messageTemplate, NoPropertyValues);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Information("Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Information(string messageTemplate, T propertyValue)
+ => Write(LogEventLevel.Information, messageTemplate, propertyValue);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Information("Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Information(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ => Write(LogEventLevel.Information, messageTemplate, propertyValue0, propertyValue1);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Information("Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Information(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
+ => Write(LogEventLevel.Information, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Message template describing the event.
+ /// Objects positionally formatted into the message template.
+ ///
+ /// Log.Information("Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Information(string messageTemplate, params object?[]? propertyValues)
+ => Information((Exception?)null, messageTemplate, propertyValues);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ ///
+ /// Log.Information(ex, "Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Information(Exception? exception, string messageTemplate)
+ => Write(LogEventLevel.Information, exception, messageTemplate, NoPropertyValues);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Information(ex, "Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Information(Exception? exception, string messageTemplate, T propertyValue)
+ => Write(LogEventLevel.Information, exception, messageTemplate, propertyValue);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Information(ex, "Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Information(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ => Write(LogEventLevel.Information, exception, messageTemplate, propertyValue0, propertyValue1);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Information(ex, "Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Information(Exception? exception, string messageTemplate, T0 propertyValue0,
+ T1 propertyValue1, T2 propertyValue2)
+ => Write(LogEventLevel.Information, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Objects positionally formatted into the message template.
+ ///
+ /// Log.Information(ex, "Processed {RecordCount} records in {TimeMS}.", records.Length, sw.ElapsedMilliseconds);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Information(Exception? exception, string messageTemplate, params object?[]? propertyValues)
+ => Write(LogEventLevel.Information, exception, messageTemplate, propertyValues);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ ///
+ /// Log.Warning("Skipped {SkipCount} records.", skippedRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Warning(string messageTemplate)
+ => Write(LogEventLevel.Warning, messageTemplate, NoPropertyValues);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Warning("Skipped {SkipCount} records.", skippedRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Warning(string messageTemplate, T propertyValue)
+ => Write(LogEventLevel.Warning, messageTemplate, propertyValue);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Warning("Skipped {SkipCount} records.", skippedRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Warning(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ => Write(LogEventLevel.Warning, messageTemplate, propertyValue0, propertyValue1);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Warning("Skipped {SkipCount} records.", skippedRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Warning(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
+ => Write(LogEventLevel.Warning, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Message template describing the event.
+ /// Objects positionally formatted into the message template.
+ ///
+ /// Log.Warning("Skipped {SkipCount} records.", skippedRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Warning(string messageTemplate, params object?[]? propertyValues)
+ => Warning((Exception?)null, messageTemplate, propertyValues);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ ///
+ /// Log.Warning(ex, "Skipped {SkipCount} records.", skippedRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Warning(Exception? exception, string messageTemplate)
+ => Write(LogEventLevel.Warning, exception, messageTemplate, NoPropertyValues);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Warning(ex, "Skipped {SkipCount} records.", skippedRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Warning(Exception? exception, string messageTemplate, T propertyValue)
+ => Write(LogEventLevel.Warning, exception, messageTemplate, propertyValue);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Warning(ex, "Skipped {SkipCount} records.", skippedRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Warning(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ => Write(LogEventLevel.Warning, exception, messageTemplate, propertyValue0, propertyValue1);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Warning(ex, "Skipped {SkipCount} records.", skippedRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Warning(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1,
+ T2 propertyValue2)
+ => Write(LogEventLevel.Warning, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Objects positionally formatted into the message template.
+ ///
+ /// Log.Warning(ex, "Skipped {SkipCount} records.", skippedRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Warning(Exception? exception, string messageTemplate, params object?[]? propertyValues)
+ => Write(LogEventLevel.Warning, exception, messageTemplate, propertyValues);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ ///
+ /// Log.Error("Failed {ErrorCount} records.", brokenRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Error(string messageTemplate)
+ => Write(LogEventLevel.Error, messageTemplate, NoPropertyValues);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Error("Failed {ErrorCount} records.", brokenRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Error(string messageTemplate, T propertyValue)
+ => Write(LogEventLevel.Error, messageTemplate, propertyValue);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Error("Failed {ErrorCount} records.", brokenRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Error(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ => Write(LogEventLevel.Error, messageTemplate, propertyValue0, propertyValue1);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Error("Failed {ErrorCount} records.", brokenRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Error(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
+ => Write(LogEventLevel.Error, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Message template describing the event.
+ /// Objects positionally formatted into the message template.
+ ///
+ /// Log.Error("Failed {ErrorCount} records.", brokenRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Error(string messageTemplate, params object?[]? propertyValues)
+ => Error((Exception?)null, messageTemplate, propertyValues);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ ///
+ /// Log.Error(ex, "Failed {ErrorCount} records.", brokenRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Error(Exception? exception, string messageTemplate)
+ => Write(LogEventLevel.Error, exception, messageTemplate, NoPropertyValues);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Error(ex, "Failed {ErrorCount} records.", brokenRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Error(Exception? exception, string messageTemplate, T propertyValue)
+ => Write(LogEventLevel.Error, exception, messageTemplate, propertyValue);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Error(ex, "Failed {ErrorCount} records.", brokenRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Error(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ => Write(LogEventLevel.Error, exception, messageTemplate, propertyValue0, propertyValue1);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Error(ex, "Failed {ErrorCount} records.", brokenRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Error(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1,
+ T2 propertyValue2)
+ => Write(LogEventLevel.Error, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Objects positionally formatted into the message template.
+ ///
+ /// Log.Error(ex, "Failed {ErrorCount} records.", brokenRecords.Length);
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Error(Exception? exception, string messageTemplate, params object?[]? propertyValues)
+ => Write(LogEventLevel.Error, exception, messageTemplate, propertyValues);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ ///
+ /// Log.Fatal("Process terminating.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Fatal(string messageTemplate)
+ => Write(LogEventLevel.Fatal, messageTemplate, NoPropertyValues);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Fatal("Process terminating.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Fatal(string messageTemplate, T propertyValue)
+ => Write(LogEventLevel.Fatal, messageTemplate, propertyValue);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Fatal("Process terminating.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Fatal(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ => Write(LogEventLevel.Fatal, messageTemplate, propertyValue0, propertyValue1);
+
+ ///
+ /// Write a log event with the level.
+ ///
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Fatal("Process terminating.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Fatal(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
+ => Write(LogEventLevel.Fatal, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Message template describing the event.
+ /// Objects positionally formatted into the message template.
+ ///
+ /// Log.Fatal("Process terminating.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Fatal(string messageTemplate, params object?[]? propertyValues)
+ => Fatal((Exception?)null, messageTemplate, propertyValues);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ ///
+ /// Log.Fatal(ex, "Process terminating.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Fatal(Exception? exception, string messageTemplate)
+ => Write(LogEventLevel.Fatal, exception, messageTemplate, NoPropertyValues);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Fatal(ex, "Process terminating.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Fatal(Exception? exception, string messageTemplate, T propertyValue)
+ => Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValue);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Fatal(ex, "Process terminating.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Fatal(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ => Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValue0, propertyValue1);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ /// Object positionally formatted into the message template.
+ ///
+ /// Log.Fatal(ex, "Process terminating.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Fatal(Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1,
+ T2 propertyValue2)
+ => Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValue0, propertyValue1, propertyValue2);
+
+ ///
+ /// Write a log event with the level and associated exception.
+ ///
+ /// Exception related to the event.
+ /// Message template describing the event.
+ /// Objects positionally formatted into the message template.
+ ///
+ /// Log.Fatal(ex, "Process terminating.");
+ ///
+ [MessageTemplateFormatMethod("messageTemplate")]
+ public void Fatal(Exception? exception, string messageTemplate, params object?[]? propertyValues)
+ => Write(LogEventLevel.Fatal, exception, messageTemplate, propertyValues);
+}
\ No newline at end of file
diff --git a/src/Serilog.Extensions.Hosting/Extensions/Hosting/ReloadableLogger.cs b/src/Serilog.Extensions.Hosting/Extensions/Hosting/ReloadableLogger.cs
index 729ae35..74d0169 100644
--- a/src/Serilog.Extensions.Hosting/Extensions/Hosting/ReloadableLogger.cs
+++ b/src/Serilog.Extensions.Hosting/Extensions/Hosting/ReloadableLogger.cs
@@ -12,12 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#if !NO_RELOADABLE_LOGGER
-
-using System;
-using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
-using System.Threading;
using Serilog.Core;
using Serilog.Events;
@@ -29,9 +25,9 @@ namespace Serilog.Extensions.Hosting;
/// A Serilog that can be reconfigured without invalidating existing
/// instances derived from it.
///
-public sealed class ReloadableLogger : ILogger, IReloadableLogger, IDisposable
+public sealed class ReloadableLogger : LoggerBase, ILogger, IReloadableLogger, IDisposable
{
- readonly object _sync = new object();
+ readonly object _sync = new();
Logger _logger;
// One-way; if the value is `true` it can never again be made `false`, allowing "double-checked" reads. If
@@ -84,7 +80,11 @@ public Logger Freeze()
// https://github.com/dotnet/runtime/issues/20500#issuecomment-284774431
// Publish `_logger` and `_frozen`. This is useful here because it means that once the logger is frozen - which
// we always expect - reads don't require any synchronization/interlocked instructions.
+#if FEATURE_MBPW
Interlocked.MemoryBarrierProcessWide();
+#else
+ Thread.MemoryBarrier();
+#endif
return _logger;
}
@@ -100,7 +100,7 @@ public void Dispose()
///
public ILogger ForContext(ILogEventEnricher enricher)
{
- if (enricher == null) return this;
+ if (enricher == null!) return this;
if (_frozen)
return _logger.ForContext(enricher);
@@ -112,7 +112,7 @@ public ILogger ForContext(ILogEventEnricher enricher)
///
public ILogger ForContext(IEnumerable enrichers)
{
- if (enrichers == null) return this;
+ if (enrichers == null!) return this;
if (_frozen)
return _logger.ForContext(enrichers);
@@ -122,9 +122,9 @@ public ILogger ForContext(IEnumerable enrichers)
}
///
- public ILogger ForContext(string propertyName, object value, bool destructureObjects = false)
+ public ILogger ForContext(string propertyName, object? value, bool destructureObjects = false)
{
- if (propertyName == null) return this;
+ if (propertyName == null!) return this;
if (_frozen)
return _logger.ForContext(propertyName, value, destructureObjects);
@@ -146,7 +146,7 @@ public ILogger ForContext()
///
public ILogger ForContext(Type source)
{
- if (source == null) return this;
+ if (source == null!) return this;
if (_frozen)
return _logger.ForContext(source);
@@ -155,8 +155,8 @@ public ILogger ForContext(Type source)
return new CachingReloadableLogger(this, _logger, this, p => p.ForContext(source));
}
- ///
- public void Write(LogEvent logEvent)
+ ///
+ public override void Write(LogEvent logEvent)
{
if (_frozen)
{
@@ -170,8 +170,8 @@ public void Write(LogEvent logEvent)
}
}
- ///
- public void Write(LogEventLevel level, string messageTemplate)
+ ///
+ public override void Write(LogEventLevel level, string messageTemplate)
{
if (_frozen)
{
@@ -185,8 +185,8 @@ public void Write(LogEventLevel level, string messageTemplate)
}
}
- ///
- public void Write(LogEventLevel level, string messageTemplate, T propertyValue)
+ ///
+ public override void Write(LogEventLevel level, string messageTemplate, T propertyValue)
{
if (_frozen)
{
@@ -200,8 +200,8 @@ public void Write(LogEventLevel level, string messageTemplate, T propertyValu
}
}
- ///
- public void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ ///
+ public override void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
{
if (_frozen)
{
@@ -215,8 +215,8 @@ public void Write(LogEventLevel level, string messageTemplate, T0 proper
}
}
- ///
- public void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1,
+ ///
+ public override void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1,
T2 propertyValue2)
{
if (_frozen)
@@ -231,8 +231,8 @@ public void Write(LogEventLevel level, string messageTemplate, T0 pr
}
}
- ///
- public void Write(LogEventLevel level, string messageTemplate, params object[] propertyValues)
+ ///
+ public override void Write(LogEventLevel level, string messageTemplate, params object?[]? propertyValues)
{
if (_frozen)
{
@@ -246,8 +246,8 @@ public void Write(LogEventLevel level, string messageTemplate, params object[] p
}
}
- ///
- public void Write(LogEventLevel level, Exception exception, string messageTemplate)
+ ///
+ public override void Write(LogEventLevel level, Exception? exception, string messageTemplate)
{
if (_frozen)
{
@@ -261,8 +261,8 @@ public void Write(LogEventLevel level, Exception exception, string messageTempla
}
}
- ///
- public void Write(LogEventLevel level, Exception exception, string messageTemplate, T propertyValue)
+ ///
+ public override void Write(LogEventLevel level, Exception? exception, string messageTemplate, T propertyValue)
{
if (_frozen)
{
@@ -276,8 +276,8 @@ public void Write(LogEventLevel level, Exception exception, string messageTem
}
}
- ///
- public void Write(LogEventLevel level, Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
+ ///
+ public override void Write(LogEventLevel level, Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
{
if (_frozen)
{
@@ -291,8 +291,8 @@ public void Write(LogEventLevel level, Exception exception, string messa
}
}
- ///
- public void Write(LogEventLevel level, Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1,
+ ///
+ public override void Write(LogEventLevel level, Exception? exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1,
T2 propertyValue2)
{
if (_frozen)
@@ -307,8 +307,8 @@ public void Write(LogEventLevel level, Exception exception, string m
}
}
- ///
- public void Write(LogEventLevel level, Exception exception, string messageTemplate, params object[] propertyValues)
+ ///
+ public override void Write(LogEventLevel level, Exception? exception, string messageTemplate, params object?[]? propertyValues)
{
if (_frozen)
{
@@ -335,10 +335,13 @@ public bool IsEnabled(LogEventLevel level)
return _logger.IsEnabled(level);
}
}
-
+
///
- public bool BindMessageTemplate(string messageTemplate, object[] propertyValues, out MessageTemplate parsedTemplate,
- out IEnumerable boundProperties)
+ public bool BindMessageTemplate(string messageTemplate, object?[]? propertyValues,
+ [NotNullWhen(true)]
+ out MessageTemplate? parsedTemplate,
+ [NotNullWhen(true)]
+ out IEnumerable? boundProperties)
{
if (_frozen)
{
@@ -352,7 +355,7 @@ public bool BindMessageTemplate(string messageTemplate, object[] propertyValues,
}
///
- public bool BindProperty(string propertyName, object value, bool destructureObjects, out LogEventProperty property)
+ public bool BindProperty(string? propertyName, object? value, bool destructureObjects, [NotNullWhen(true)] out LogEventProperty? property)
{
if (_frozen)
{
@@ -365,8 +368,10 @@ public bool BindProperty(string propertyName, object value, bool destructureObje
}
}
+ // `newRoot` is null when the second returned tuple argument is `false`, but the signature of the method doesn't currently
+ // allow this to be expressed.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- (ILogger, bool) UpdateForCaller(ILogger root, ILogger cached, IReloadableLogger caller, out ILogger newRoot, out ILogger newCached, out bool frozen)
+ (ILogger, bool) UpdateForCaller(ILogger root, ILogger? cached, IReloadableLogger caller, out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
// Synchronization on `_sync` is not required in this method; it will be called without a lock
// if `_frozen` and under a lock if not.
@@ -381,9 +386,9 @@ public bool BindProperty(string propertyName, object value, bool destructureObje
return (newCached, true);
}
- if (cached != null && root == _logger)
+ if (cached != null! && root == _logger)
{
- newRoot = default;
+ newRoot = default!;
newCached = default;
frozen = false;
return (cached, false);
@@ -395,7 +400,7 @@ public bool BindProperty(string propertyName, object value, bool destructureObje
return (newCached, true);
}
- internal bool InvokeIsEnabled(ILogger root, ILogger cached, IReloadableLogger caller, LogEventLevel level, out bool isEnabled, out ILogger newRoot, out ILogger newCached, out bool frozen)
+ internal bool InvokeIsEnabled(ILogger root, ILogger? cached, IReloadableLogger caller, LogEventLevel level, out bool isEnabled, out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
if (_frozen)
{
@@ -412,9 +417,9 @@ internal bool InvokeIsEnabled(ILogger root, ILogger cached, IReloadableLogger ca
}
}
- internal bool InvokeBindMessageTemplate(ILogger root, ILogger cached, IReloadableLogger caller, string messageTemplate,
- object[] propertyValues, out MessageTemplate parsedTemplate, out IEnumerable boundProperties,
- out bool canBind, out ILogger newRoot, out ILogger newCached, out bool frozen)
+ internal bool InvokeBindMessageTemplate(ILogger root, ILogger? cached, IReloadableLogger caller, string messageTemplate,
+ object?[]? propertyValues, [NotNullWhen(true)] out MessageTemplate? parsedTemplate, [NotNullWhen(true)] out IEnumerable? boundProperties,
+ out bool canBind, out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
if (_frozen)
{
@@ -431,9 +436,9 @@ internal bool InvokeBindMessageTemplate(ILogger root, ILogger cached, IReloadabl
}
}
- internal bool InvokeBindProperty(ILogger root, ILogger cached, IReloadableLogger caller, string propertyName,
- object propertyValue, bool destructureObjects, out LogEventProperty property,
- out bool canBind, out ILogger newRoot, out ILogger newCached, out bool frozen)
+ internal bool InvokeBindProperty(ILogger root, ILogger? cached, IReloadableLogger caller, string? propertyName,
+ object? propertyValue, bool destructureObjects, [NotNullWhen(true)] out LogEventProperty? property,
+ out bool canBind, out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
if (_frozen)
{
@@ -450,7 +455,7 @@ internal bool InvokeBindProperty(ILogger root, ILogger cached, IReloadableLogger
}
}
- internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller, LogEvent logEvent, out ILogger newRoot, out ILogger newCached, out bool frozen)
+ internal bool InvokeWrite(ILogger root, ILogger? cached, IReloadableLogger caller, LogEvent logEvent, out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
if (_frozen)
{
@@ -467,8 +472,8 @@ internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller
}
}
- internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller, LogEventLevel level, string messageTemplate,
- out ILogger newRoot, out ILogger newCached, out bool frozen)
+ internal bool InvokeWrite(ILogger root, ILogger? cached, IReloadableLogger caller, LogEventLevel level, string messageTemplate,
+ out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
if (_frozen)
{
@@ -485,9 +490,9 @@ internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller
}
}
- internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller, LogEventLevel level, string messageTemplate,
+ internal bool InvokeWrite(ILogger root, ILogger? cached, IReloadableLogger caller, LogEventLevel level, string messageTemplate,
T propertyValue,
- out ILogger newRoot, out ILogger newCached, out bool frozen)
+ out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
if (_frozen)
{
@@ -504,9 +509,9 @@ internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger cal
}
}
- internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller, LogEventLevel level, string messageTemplate,
+ internal bool InvokeWrite(ILogger root, ILogger? cached, IReloadableLogger caller, LogEventLevel level, string messageTemplate,
T0 propertyValue0, T1 propertyValue1,
- out ILogger newRoot, out ILogger newCached, out bool frozen)
+ out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
if (_frozen)
{
@@ -523,9 +528,9 @@ internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogge
}
}
- internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller, LogEventLevel level, string messageTemplate,
+ internal bool InvokeWrite(ILogger root, ILogger? cached, IReloadableLogger caller, LogEventLevel level, string messageTemplate,
T0 propertyValue0, T1 propertyValue1, T2 propertyValue2,
- out ILogger newRoot, out ILogger newCached, out bool frozen)
+ out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
if (_frozen)
{
@@ -542,9 +547,9 @@ internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableL
}
}
- internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller, LogEventLevel level, string messageTemplate,
- object[] propertyValues,
- out ILogger newRoot, out ILogger newCached, out bool frozen)
+ internal bool InvokeWrite(ILogger root, ILogger? cached, IReloadableLogger caller, LogEventLevel level, string messageTemplate,
+ object?[]? propertyValues,
+ out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
if (_frozen)
{
@@ -561,8 +566,8 @@ internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller
}
}
- internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller, LogEventLevel level, Exception exception, string messageTemplate,
- out ILogger newRoot, out ILogger newCached, out bool frozen)
+ internal bool InvokeWrite(ILogger root, ILogger? cached, IReloadableLogger caller, LogEventLevel level, Exception? exception, string messageTemplate,
+ out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
if (_frozen)
{
@@ -579,9 +584,9 @@ internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller
}
}
- internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller, LogEventLevel level, Exception exception, string messageTemplate,
+ internal bool InvokeWrite(ILogger root, ILogger? cached, IReloadableLogger caller, LogEventLevel level, Exception? exception, string messageTemplate,
T propertyValue,
- out ILogger newRoot, out ILogger newCached, out bool frozen)
+ out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
if (_frozen)
{
@@ -598,9 +603,9 @@ internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger cal
}
}
- internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller, LogEventLevel level, Exception exception, string messageTemplate,
+ internal bool InvokeWrite(ILogger root, ILogger? cached, IReloadableLogger caller, LogEventLevel level, Exception? exception, string messageTemplate,
T0 propertyValue0, T1 propertyValue1,
- out ILogger newRoot, out ILogger newCached, out bool frozen)
+ out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
if (_frozen)
{
@@ -617,9 +622,9 @@ internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogge
}
}
- internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller, LogEventLevel level, Exception exception, string messageTemplate,
+ internal bool InvokeWrite(ILogger root, ILogger? cached, IReloadableLogger caller, LogEventLevel level, Exception? exception, string messageTemplate,
T0 propertyValue0, T1 propertyValue1, T2 propertyValue2,
- out ILogger newRoot, out ILogger newCached, out bool frozen)
+ out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
if (_frozen)
{
@@ -636,9 +641,9 @@ internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableL
}
}
- internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller, LogEventLevel level, Exception exception, string messageTemplate,
- object[] propertyValues,
- out ILogger newRoot, out ILogger newCached, out bool frozen)
+ internal bool InvokeWrite(ILogger root, ILogger? cached, IReloadableLogger caller, LogEventLevel level, Exception? exception, string messageTemplate,
+ object?[]? propertyValues,
+ out ILogger newRoot, out ILogger? newCached, out bool frozen)
{
if (_frozen)
{
@@ -658,11 +663,11 @@ internal bool InvokeWrite(ILogger root, ILogger cached, IReloadableLogger caller
internal bool CreateChild(
ILogger root,
IReloadableLogger parent,
- ILogger cachedParent,
+ ILogger? cachedParent,
Func configureChild,
out ILogger child,
out ILogger newRoot,
- out ILogger newCached,
+ out ILogger? newCached,
out bool frozen)
{
if (_frozen)
@@ -675,11 +680,9 @@ internal bool CreateChild(
// No synchronization, here - a lot of loggers are created and thrown away again without ever being used,
// so we just return a lazy wrapper.
child = new CachingReloadableLogger(this, root, parent, configureChild);
- newRoot = default;
+ newRoot = default!;
newCached = default;
frozen = default;
return false;
}
}
-
-#endif
diff --git a/src/Serilog.Extensions.Hosting/Extensions/Hosting/SerilogLoggerFactory.cs b/src/Serilog.Extensions.Hosting/Extensions/Hosting/SerilogLoggerFactory.cs
deleted file mode 100644
index f60dae3..0000000
--- a/src/Serilog.Extensions.Hosting/Extensions/Hosting/SerilogLoggerFactory.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2018 Serilog Contributors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// 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 the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using System.ComponentModel;
-using Microsoft.Extensions.Logging;
-using Serilog.Debugging;
-using Serilog.Extensions.Logging;
-
-// To line up with the convention used elsewhere in the *.Extensions libraries, this
-// should have been Serilog.Extensions.Hosting.
-// ReSharper disable once CheckNamespace
-namespace Serilog.Hosting;
-
-///
-/// Implements so that we can inject Serilog Logger.
-///
-[Obsolete("Replaced with Serilog.Extensions.Logging.SerilogLoggerFactory")]
-[EditorBrowsable(EditorBrowsableState.Never)]
-public class SerilogLoggerFactory : ILoggerFactory
-{
- readonly SerilogLoggerProvider _provider;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The Serilog logger; if not supplied, the static will be used.
- /// When true, dispose when the framework disposes the provider. If the
- /// logger is not specified but is true, the method will be
- /// called on the static class instead.
- public SerilogLoggerFactory(ILogger logger = null, bool dispose = false)
- {
- _provider = new SerilogLoggerProvider(logger, dispose);
- }
-
- ///
- /// Disposes the provider.
- ///
- public void Dispose()
- {
- _provider.Dispose();
- }
-
- ///
- /// Creates a new instance.
- ///
- /// The category name for messages produced by the logger.
- ///
- /// The .
- ///
- public Microsoft.Extensions.Logging.ILogger CreateLogger(string categoryName)
- {
- return _provider.CreateLogger(categoryName);
- }
-
- ///
- /// Adds an to the logging system.
- ///
- /// The .
- public void AddProvider(ILoggerProvider provider)
- {
- SelfLog.WriteLine("Ignoring add logger provider {0}", provider);
- }
-}
diff --git a/src/Serilog.Extensions.Hosting/Properties/AssemblyInfo.cs b/src/Serilog.Extensions.Hosting/Properties/AssemblyInfo.cs
index 8ec980f..22cba5d 100644
--- a/src/Serilog.Extensions.Hosting/Properties/AssemblyInfo.cs
+++ b/src/Serilog.Extensions.Hosting/Properties/AssemblyInfo.cs
@@ -1,7 +1,4 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-[assembly: AssemblyVersion("7.0.0.0")]
+using System.Runtime.CompilerServices;
[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 bca67be..12ff5b6 100644
--- a/src/Serilog.Extensions.Hosting/Serilog.Extensions.Hosting.csproj
+++ b/src/Serilog.Extensions.Hosting/Serilog.Extensions.Hosting.csproj
@@ -2,45 +2,42 @@
Serilog support for .NET Core logging in hosted services
-
- 8.0.0
Microsoft;Serilog Contributors
- net462;netstandard2.0;net6.0;net7.0;net8.0
- latest
- true
- true
- ../../assets/Serilog.snk
- true
- true
+ net462;netstandard2.0;netstandard2.1;net8.0;net9.0
serilog;aspnet;aspnetcore;hosting
icon.png
https://github.com/serilog/serilog-extensions-hosting
Apache-2.0
- https://github.com/serilog/serilog-extensions-hosting
- git
- false
Serilog
README.md
-
- $(DefineConstants);NO_RELOADABLE_LOGGER
+
+ $(DefineConstants);FEATURE_MBPW
+
+
+
+ $(DefineConstants);FEATURE_MBPW
+
+
+
+ $(DefineConstants);FEATURE_MBPW
-
-
+
+
-
-
-
-
+
+
+
+
diff --git a/src/Serilog.Extensions.Hosting/SerilogHostBuilderExtensions.cs b/src/Serilog.Extensions.Hosting/SerilogHostBuilderExtensions.cs
index d8b8c4a..f777880 100644
--- a/src/Serilog.Extensions.Hosting/SerilogHostBuilderExtensions.cs
+++ b/src/Serilog.Extensions.Hosting/SerilogHostBuilderExtensions.cs
@@ -39,9 +39,9 @@ public static class SerilogHostBuilderExtensions
/// The host builder.
public static IHostBuilder UseSerilog(
this IHostBuilder builder,
- ILogger logger = null,
+ ILogger? logger = null,
bool dispose = false,
- LoggerProviderCollection providers = null)
+ LoggerProviderCollection? providers = null)
{
if (builder == null) throw new ArgumentNullException(nameof(builder));
diff --git a/src/Serilog.Extensions.Hosting/SerilogServiceCollectionExtensions.cs b/src/Serilog.Extensions.Hosting/SerilogServiceCollectionExtensions.cs
index d0d21af..9e9591b 100644
--- a/src/Serilog.Extensions.Hosting/SerilogServiceCollectionExtensions.cs
+++ b/src/Serilog.Extensions.Hosting/SerilogServiceCollectionExtensions.cs
@@ -12,9 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using System;
using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Serilog.Extensions.Hosting;
using Serilog.Extensions.Logging;
@@ -55,9 +53,9 @@ public RegisteredLogger(ILogger logger)
/// The service collection.
public static IServiceCollection AddSerilog(
this IServiceCollection collection,
- ILogger logger = null,
+ ILogger? logger = null,
bool dispose = false,
- LoggerProviderCollection providers = null)
+ LoggerProviderCollection? providers = null)
{
if (collection == null) throw new ArgumentNullException(nameof(collection));
@@ -75,7 +73,7 @@ public static IServiceCollection AddSerilog(
}
else
{
- collection.AddSingleton(services => new SerilogLoggerFactory(logger, dispose));
+ collection.AddSingleton(_ => new SerilogLoggerFactory(logger, dispose));
}
if (logger != null)
@@ -110,7 +108,7 @@ public static IServiceCollection AddSerilog(
if (configureLogger == null) throw new ArgumentNullException(nameof(configureLogger));
return AddSerilog(
collection,
- (services, loggerConfiguration) =>
+ (_, loggerConfiguration) =>
configureLogger(loggerConfiguration),
preserveStaticLogger: preserveStaticLogger,
writeToProviders: writeToProviders);
@@ -138,14 +136,10 @@ public static IServiceCollection AddSerilog(
if (configureLogger == null) throw new ArgumentNullException(nameof(configureLogger));
// This check is eager; replacing the bootstrap logger after calling this method is not supported.
-#if !NO_RELOADABLE_LOGGER
var reloadable = Log.Logger as ReloadableLogger;
var useReload = reloadable != null && !preserveStaticLogger;
-#else
- const bool useReload = false;
-#endif
- LoggerProviderCollection loggerProviders = null;
+ LoggerProviderCollection? loggerProviders = null;
if (writeToProviders)
{
loggerProviders = new LoggerProviderCollection();
@@ -154,7 +148,6 @@ public static IServiceCollection AddSerilog(
collection.AddSingleton(services =>
{
ILogger logger;
-#if !NO_RELOADABLE_LOGGER
if (useReload)
{
reloadable!.Reload(cfg =>
@@ -169,7 +162,6 @@ public static IServiceCollection AddSerilog(
logger = reloadable.Freeze();
}
else
-#endif
{
var loggerConfiguration = new LoggerConfiguration();
@@ -195,7 +187,7 @@ public static IServiceCollection AddSerilog(
{
var logger = services.GetRequiredService().Logger;
- ILogger registeredLogger = null;
+ ILogger? registeredLogger = null;
if (preserveStaticLogger)
{
registeredLogger = logger;
@@ -231,7 +223,7 @@ static void ConfigureDiagnosticContext(IServiceCollection collection, bool useRe
// Consumed by e.g. middleware
collection.AddSingleton(services =>
{
- ILogger logger = useRegisteredLogger ? services.GetRequiredService().Logger : null;
+ ILogger? logger = useRegisteredLogger ? services.GetRequiredService().Logger : null;
return new DiagnosticContext(logger);
});
// Consumed by user code
diff --git a/test/Serilog.Extensions.Hosting.Tests/DiagnosticContextTests.cs b/test/Serilog.Extensions.Hosting.Tests/DiagnosticContextTests.cs
index d66114b..ba36bc7 100644
--- a/test/Serilog.Extensions.Hosting.Tests/DiagnosticContextTests.cs
+++ b/test/Serilog.Extensions.Hosting.Tests/DiagnosticContextTests.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-using Serilog.Events;
+using Serilog.Events;
using Serilog.Extensions.Hosting.Tests.Support;
using Xunit;
@@ -36,7 +33,7 @@ public async Task PropertiesAreCollectedInAnActiveContext()
dc.Set(Some.String("second"), Some.Int32());
Assert.True(collector.TryComplete(out var properties, out var exception));
- Assert.Equal(2, properties.Count());
+ Assert.Equal(2, properties!.Count());
Assert.Null(exception);
Assert.False(collector.TryComplete(out _, out _));
@@ -99,7 +96,7 @@ public void ExistingPropertiesCanBeUpdated()
dc.Set("name", 20);
Assert.True(collector.TryComplete(out var properties, out var exception));
- var prop = Assert.Single(properties);
+ var prop = Assert.Single(properties!);
var scalar = Assert.IsType(prop.Value);
Assert.Equal(20, scalar.Value);
Assert.Null(exception);
@@ -115,6 +112,6 @@ public void ExistingExceptionCanBeUpdated()
dc.SetException(new Exception("ex2"));
Assert.True(collector.TryComplete(out _, out var collectedException));
- Assert.Equal("ex2", collectedException.Message);
+ Assert.Equal("ex2", collectedException!.Message);
}
}
diff --git a/test/Serilog.Extensions.Hosting.Tests/ReloadableLoggerTests.cs b/test/Serilog.Extensions.Hosting.Tests/ReloadableLoggerTests.cs
index 80a0239..cd24597 100644
--- a/test/Serilog.Extensions.Hosting.Tests/ReloadableLoggerTests.cs
+++ b/test/Serilog.Extensions.Hosting.Tests/ReloadableLoggerTests.cs
@@ -1,8 +1,4 @@
-#if !NO_RELOADABLE_LOGGER
-
-using System.Collections.Generic;
-using System.Linq;
-using Serilog.Core;
+using Serilog.Core;
using Serilog.Events;
using Serilog.Extensions.Hosting.Tests.Support;
using Xunit;
@@ -103,5 +99,3 @@ public void ReloadableLoggersRecordEnrichment()
Assert.All(emittedEvents, e => Assert.Equal(2, e.Properties.Count));
}
}
-
-#endif
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 1f5c9d6..2d764f6 100644
--- a/test/Serilog.Extensions.Hosting.Tests/Serilog.Extensions.Hosting.Tests.csproj
+++ b/test/Serilog.Extensions.Hosting.Tests/Serilog.Extensions.Hosting.Tests.csproj
@@ -1,15 +1,10 @@
- net4.8;net6.0;net7.0;net8.0
- ../../assets/Serilog.snk
- true
- true
- latest
-
-
-
- $(DefineConstants);NO_RELOADABLE_LOGGER
+
+ net4.8;net6.0;net8.0;net9.0
+ false
@@ -17,10 +12,10 @@
-
-
-
-
+
+
+
+
diff --git a/test/Serilog.Extensions.Hosting.Tests/SerilogHostBuilderExtensionsTests.cs b/test/Serilog.Extensions.Hosting.Tests/SerilogHostBuilderExtensionsTests.cs
index 53dce78..02aed72 100644
--- a/test/Serilog.Extensions.Hosting.Tests/SerilogHostBuilderExtensionsTests.cs
+++ b/test/Serilog.Extensions.Hosting.Tests/SerilogHostBuilderExtensionsTests.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
@@ -61,9 +59,9 @@ public void ServicesAreRegisteredWhenCallingUseSerilogWithConfigureDelegate()
provider.GetRequiredService();
}
- private class FakeHostBuilder : IHostBuilder
+ class FakeHostBuilder : IHostBuilder
{
- private readonly IServiceCollection _collection;
+ readonly IServiceCollection _collection;
public FakeHostBuilder(IServiceCollection collection) => _collection = collection;
@@ -79,16 +77,18 @@ public IHostBuilder ConfigureAppConfiguration(Action configureDelegate)
{
- configureDelegate(null, _collection);
+ configureDelegate(null!, _collection);
return this;
}
public IHostBuilder UseServiceProviderFactory(IServiceProviderFactory factory)
+ where TContainerBuilder: notnull
{
throw new NotImplementedException();
}
public IHostBuilder UseServiceProviderFactory(Func> factory)
+ where TContainerBuilder: notnull
{
throw new NotImplementedException();
}
@@ -103,6 +103,6 @@ public IHost Build()
throw new NotImplementedException();
}
- public IDictionary