trying to follow this tutorial : https://nblumhardt.com/2019/10/serilog-in-aspnetcore-3/
I managed to add the Serilog to my app (.NET Core 3.1)
but I cannot modify the CreateHostBuilder function, since it does not recognize UseSerilog() function
I have checked for a solution, but everyone seems to use that code
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Serilog;
namespace MyApi
{
public class Program
{
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.Console()
.CreateLogger();
try
{
Log.Information("Starting up");
CreateHostBuilder(args).Build().Run();
}
catch (Exception ex)
{
Log.Fatal(ex, "Application start-up failed");
}
finally
{
Log.CloseAndFlush();
}
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSerilog() // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< unknown function
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
what am I missing here ?
thanks for your help
Answer provided by Alex Lyalka : packages were missing
dotnet add package Serilog.AspNetCore