2

I am working on a web app where we are trying to configure logging using Serilog and using email as a log delivery system.

In my Program.cs file, I have

builder.Host.UseSerilog((ctx, lc) => lc
    .ReadFrom.Configuration(ctx.Configuration));

In my appsettings.json file, I have two WriteTo's: one to a local file on my machine and one to email.

The WriteTo file option is working just fine as the program stands today; when running the code in VS2022, it logs the information to the file location specified in my appsettings.json file. The WriteTo email option is not working at all, I am not receiving any emails despite logs being written successfully to the local file.

The WriteTo for email is configured as follows (with identifying information removed):

{
    "Name": "EmailCustom",
    "Args": {
        "enableSsl": false,
        "fromEmail": "appname@ourorg.com",
        "mailServer": "ourmailserver.ourorg.com",
        "mailSubject": "Error in App",
        "smtpPort": 25,
        "toEmail": "myemail@ourorg.com"
    }
}

I have looked far and wide, and have not seen anyone else bring up this issue or have an example of an email configuration listed. Has anyone successfully set up email logging with Serilog in .NET 6.0 who can help me out? Thanks!

1 Answers1

1

The same topic: Serilog WriteTo.Email() failing

It seems that Serilog.Sink.Email uses old version of MailKit

Adam Szady
  • 11
  • 1