Closed eerhardt closed 1 year ago
Thanks for the heads-up @eerhardt :+1:
@nblumhardt Is this anywhere in the new future or are you accepting contributions for it?
From the look of things in https://github.com/serilog/serilog-extensions-hosting/blob/dev/src/Serilog.Extensions.Hosting/SerilogHostBuilderExtensions.cs, the is nothing closely tying the logic to IHostBuilder
or HostBuilderContet
except for the callbacks. I made the changes locally to create new extensions on IServiceCollection
that are then used by the existing extensions on IHostBuilder
and all seems fine. I could submit a PR for the this.
A PR for this would be very welcome, thanks @mburumaxwell 👍
Done. You can review it when you get a chance.
With https://github.com/dotnet/runtime/issues/61634#issuecomment-1033038101 and https://github.com/dotnet/runtime/pull/65109, Microsoft.Extensions.Hosting added a new way of creating a hosted app that doesn't use IHostBuilder.
We should add overloads to
SerilogHostBuilderExtensions
that accept anIServiceCollection
instead of anIHostBuilder
. This will allow consumers using the new HostApplicationBuilder to use Serilog easily.Since the methods will extend
IServiceCollection
, the methods should probably be namedAddSerilog
instead ofUseSerilog
. This follows the naming patterns used elsewhere.See also https://github.com/dotnet/runtime/pull/68580 and https://github.com/dotnet/aspnetcore/pull/43056
cc @davidfowl