I have an aspnet core app and I'm trying to configure serilog to send me emails, with no luck.
I have this configuration:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.File("1.log", LogEventLevel.Information, fileSizeLimitBytes: 10_000_000, rollOnFileSizeLimit: true, shared: true)
.WriteTo.Email(new EmailConnectionInfo
{
FromEmail = "xxx@gmail.com",
ToEmail = "yyy@gmail.com",
MailServer = "smtp.gmail.com",
NetworkCredentials = new NetworkCredential
{
UserName = "user",
Password = "pass"
},
EnableSsl = true,
Port = 587,
EmailSubject = "Error in app"
}, restrictedToMinimumLevel: LogEventLevel.Error, batchPostingLimit: 1)
.CreateLogger();
No emails. It writes to the file, so the logger is active. Anything I'm missing?