Hi,
I would like to use the Serilog email sink.
Serilog works with IloggerBuilder but many of is adapters use an older interface called Sinks. I can get extensions working that you cover in your tutorial (timestamped) but I can’t understand how to plug Sinks in. According to the nuget information this is how, but I can’t see where LoggerConfiguration() comes from in the interface or if it should be cast.
It says
in your application’s
Startupmethod, configure Serilog first:
using Serilog;
public class Startup
{
public Startup(IHostingEnvironment env)
{
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.Console()
.CreateLogger();
// Other startup code
Finally, for .NET Core 2.0+, in your
Startupclass’sConfigure()method, remove the existing logger configuration entries and callAddSerilog()on the providedloggingBuilder.
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(loggingBuilder =>
loggingBuilder.AddSerilog(dispose: true));
// Other services ...
}
