I am trying to implement email functionality in a C# .NET Core console application. Whenever there is an error an email has to be sent out to the users. I am not sure how to implement this. Is there a .NET Core library to do this the simple way?
I tried using the Serilog.Sink.Email library, but it does not seem to work.
Here is my code.
Log.Logger = new LoggerConfiguration()
// add console as logging target
.WriteTo.Console()
//.WriteTo.File(path: @"C:\Code\Test.txt", rollingInterval: RollingInterval.Day)
.WriteTo.File(path: @configuration.GetSection("LogPath").Value, rollingInterval: RollingInterval.Day)
.WriteTo.Email(
from: "LOG",
to: "[email protected]",
host: "exchange",
subject: "Error Log",
restrictedToMinimumLevel: LogEventLevel.Error
)
// set default minimum level
.MinimumLevel.Debug()
.CreateLogger();