i followed few tutorials and im stuck building the default dotnet 3.1 with serilog in program.cs this line wont build here is the code https://github.com/guymalka/serilog-dotnetcore/blob/master/Program.cs what reference do I need to add here?
First include nuget package reference in your .csproj file:
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
and dotnet restore
your project.
After that import the Serilog namespace in your Program.cs
file (you could do that in Startup
as well):
using Serilog;
That should be enough for you to register Serilog like so:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSerilog()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
Note that if you wish to configure other aspects, e.g., your sinks, with Serilog chances are you'll have to include separate packages:
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />