diff --git a/NLog.Web.sln b/NLog.Web.sln index d1810fce..310ec215 100644 --- a/NLog.Web.sln +++ b/NLog.Web.sln @@ -28,7 +28,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASP.NET Core 3 - VS2019", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASP.NET Core 5 NLog Example", "examples\ASP.NET Core 5\ASP.NET Core 5 NLog Example\ASP.NET Core 5 NLog Example.csproj", "{6B629300-2FD1-4465-B077-24D01E2BB5E7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASP.NET Core 6 NLog Example", "examples\ASP.NET Core 6\ASP.NET Core 6 NLog Example\ASP.NET Core 6 NLog Example.csproj", "{C7F367FA-9DFC-4AA4-81AF-1B4933EAE516}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASP.NET Core 6 NLog Example", "examples\ASP.NET Core 6\ASP.NET Core 6 NLog Example\ASP.NET Core 6 NLog Example.csproj", "{C7F367FA-9DFC-4AA4-81AF-1B4933EAE516}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/tests/NLog.Web.AspNetCore.Tests/AspNetCoreTests.cs b/tests/NLog.Web.AspNetCore.Tests/AspNetCoreTests.cs index bfd1f0b3..91749bb3 100644 --- a/tests/NLog.Web.AspNetCore.Tests/AspNetCoreTests.cs +++ b/tests/NLog.Web.AspNetCore.Tests/AspNetCoreTests.cs @@ -33,10 +33,12 @@ public void Dispose() #endregion - [Fact] - public void UseNLogShouldLogTest() + [Theory] + [InlineData(true)] + [InlineData(false)] + public void UseNLogShouldLogTest(bool useNLogWeb) { - var webhost = CreateWebHost(); + var webhost = useNLogWeb ? CreateWebHost() : CreateWebHostAddNLogWeb(); var loggerFact = GetLoggerFactory(webhost); @@ -306,6 +308,13 @@ private static IWebHost CreateWebHost(NLogAspNetCoreOptions options = null) .Build(); } + private static IWebHost CreateWebHostAddNLogWeb() + { + return CreateWebHostBuilder() + .ConfigureLogging(builder => builder.ClearProviders().AddNLogWeb()) + .Build(); + } + private static ILoggerFactory GetLoggerFactory(IWebHost webhost) { return webhost.Services.GetService();