I got this part from ChatGPT, but I haven't tried it yet. They mentioned two methods. Please check if it doesn't work, and let me know. I will verify it.
var builder = WebApplication.CreateBuilder(args);
Log.Logger = new LoggerConfiguration()
.WriteTo.Email(new EmailConnectionInfo
{
FromEmail = "[email protected]",
ToEmail = "[email protected]",
MailServer = "smtp.your-email-server.com",
NetworkCredentials = new NetworkCredential("[email protected]", "your-password"),
EmailSubject = "Log Email",
Port = 587, // SMTP port
EnableSsl = true
})
.CreateLogger();
builder.Logging.ClearProviders(); builder.Logging.AddSerilog();var app = builder.Build();
Adding another logger to Umbraco (V13)
I am trying to add another logger to Umbraco (Serilog Email Sink), however, I am unsure where to add the logger in Startup.cs. I am on Umbraco V13.
I know how to create the new
LoggerConfiguration
, but what I don't knwo is what to do with it then :-)I try to do it in code, rather than in appsettings.json, since this way, it is easier to pull in secret credential information from other places.
Any hint appreciated :-) ! Kind regards, Mikael
I got this part from ChatGPT, but I haven't tried it yet. They mentioned two methods. Please check if it doesn't work, and let me know. I will verify it.
another approach will be using appsettings.
is working on a reply...