Skip to content

Commit c54e5ac

Browse files
committed
We're bumping the major version; mark IWebHostBuilder extension methods as obsolete, so that we can eventually drop this from the package (IHostBuilder is the modern replacement).
1 parent 8ec6d5c commit c54e5ac

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/Serilog.AspNetCore/Serilog.AspNetCore.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
<None Include="..\..\assets\icon.png" Pack="true" Visible="false" PackagePath="" />
2525
</ItemGroup>
2626

27+
<PropertyGroup Condition="'$(TargetFramework)' != 'netstandard2.0' and '$(TargetFramework)' != 'netstandard2.1'">
28+
<DefineConstants>$(DefineConstants);HOSTBUILDER</DefineConstants>
29+
</PropertyGroup>
30+
2731
<ItemGroup>
2832
<PackageReference Include="Serilog" Version="2.10.0" />
2933
<PackageReference Include="Serilog.Extensions.Hosting" Version="4.1.2" />

src/Serilog.AspNetCore/SerilogWebHostBuilderExtensions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public static class SerilogWebHostBuilderExtensions
3838
/// <c>WriteTo.Providers()</c> configuration method, enabling other <see cref="ILoggerProvider"/>s to receive events. By
3939
/// default, only Serilog sinks will receive events.</param>
4040
/// <returns>The web host builder.</returns>
41+
#if HOSTBUILDER
42+
[Obsolete("Prefer UseSerilog() on IHostBuilder")]
43+
#endif
4144
public static IWebHostBuilder UseSerilog(
4245
this IWebHostBuilder builder,
4346
ILogger logger = null,
@@ -83,6 +86,9 @@ public static IWebHostBuilder UseSerilog(
8386
/// the Microsoft.Extensions.Logging API. Normally, equivalent Serilog sinks are used in place of providers. Specify
8487
/// <c>true</c> to write events to all providers.</param>
8588
/// <returns>The web host builder.</returns>
89+
#if HOSTBUILDER
90+
[Obsolete("Prefer UseSerilog() on IHostBuilder")]
91+
#endif
8692
public static IWebHostBuilder UseSerilog(
8793
this IWebHostBuilder builder,
8894
Action<WebHostBuilderContext, LoggerConfiguration> configureLogger,

test/Serilog.AspNetCore.Tests/SerilogWebHostBuilderExtensionsTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
using Serilog.Filters;
1313
using Serilog.AspNetCore.Tests.Support;
1414

15+
// Newer frameworks provide IHostBuilder
16+
#pragma warning disable CS0618
17+
1518
namespace Serilog.AspNetCore.Tests
1619
{
1720
public class SerilogWebHostBuilderExtensionsTests : IClassFixture<SerilogWebApplicationFactory>

0 commit comments

Comments
 (0)