Reputation: 1602
I receive error log using elmahcore but I want to receive the errors by email. How do I do that?
This is how I receive the errors in database.
services.AddElmah<SqlErrorLog>(options =>
{
options.ConnectionString = Configuration["ElmahConnection"];
options.ApplicationName = Configuration["ApplicationName"];
});
I am using sendgrid email but I don't know how to implement it to ElmahCOre.
EmailOptions emailOptions = new EmailOptions
{
MailRecipient = "[email protected]"
};
services.AddElmah<XmlFileErrorLog>(options =>
{
options.Path = @"errors";
options.LogPath = "~/logs";
options.Notifiers.Add(new ErrorMailNotifier("Email", emailOptions));
});
emailClass
SendGridClient client = new SendGridClient(".....");
SendGridMessage mail = new SendGridMessage();
mail.AddTo(new EmailAddress(email));
mail.From ="email";
client.SendEmailAsync(mail);
Upvotes: 1
Views: 1021
Reputation: 1602
I am able to receive emails from ElmahCore using sendgrid and also get in SQL.
EmailOptions emailOptions = new EmailOptions
{
MailRecipient = "[email protected]",
MailSender = "[email protected]",
SmtpServer = "smtp.sendgrid.net",
AuthUserName = "loginUsername",
AuthPassword = "loginPassword"
};
services.AddElmah<SqlErrorLog>(options =>
{
options.ConnectionString = Configuration["ElmahConnection"];
options.ApplicationName = Configuration["ApplicationName"];
options.Notifiers.Add(new ErrorMailNotifier("Email", emailOptions));
});
Upvotes: 1