Want to use WebHost and serilog in .NET 8

  Kiến thức lập trình

want to use serilog middleware in Webhost using belwo snippet.


Yet getting below exception as UseSerilog function is not available.

Error CS1929 ‘IWebHostBuilder’ does not contain a definition for ‘UseSerilog’ and the best extension method overload ‘SerilogHostBuilderExtensions.UseSerilog(IHostBuilder, ILogger, bool, LoggerProviderCollection)’ requires a receiver of type ‘Microsoft.Extensions.Hosting.IHostBuilder’

Commenting UseSerilog() and running with default builder throws up below exception

Application startup exception: System.InvalidOperationException: Unable to resolve service for type ‘Serilog.Extensions.Hosting.DiagnosticContext’ while attempting to activate ‘Serilog.AspNetCore.RequestLoggingMiddleware’.

consumed latest serilog nuget packages yet unable to use Serilog and WebHost in .NET 8.

Is there any alternate approach bringing up this middleware?

alternate approach bringing up this middleware?

New contributor

jayakanth battu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website