By default, when using DI, you will be using Microsoft's implementation of
ILoggerFactory. This requires no additional setup.
Third Party Logger
If you wish to use a different logging service/implementation you simply install the appropriate nuget package, or create your own which have implementations for
You need to register either this third party implementation or your own via the
IServiceCollection which becomes
IServiceProvider at runtime.
If we are using the DisCatSharp ProjectTemplates there will be a project with a
.Web. Inside is a
- Serilog.Extensions.Hosting -- Gives us the
- Serilog.Sinks.Console -- Sinks are used to direct where logs go. In this case we need it for outputting to console
using Serilog; // unrelated code not shown for brevity builder.Host.UseSerilog( (context, lc) => lc.WriteTo.Console()); // Our logs are directed to the console var app = builder.Build(); app.Run();