Closed qwertyuiope closed 9 months ago
adding quotes around the port no did the trick for me: "port": "587"
Regards Edu,
I just tried adding quotes and didnt work... it keeps showing me port 25 instead of 587
I doubt you can configure it from a file or other source at least because networkCredentials
is an interface. How would configuration code know which implementation to use?
Is it possible to provide such functionality?
@ArnaudB88 you can work around this problem by defining your own extension method with your own settings type which doesn't have interfaces, like this:
public static LoggerConfiguration Email(
this LoggerSinkConfiguration loggerConfiguration,
MyEmailConnectionInfo emailConnectionInfo,
string outputTemplate = DefaultOutputTemplate,
LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose,
int batchPostingLimit = 100,
TimeSpan? period = default,
IFormatProvider formatProvider = null,
string mailSubject = "Log Email")
{
var emailConnectionInfo =
myEmailConnectionInfo.ToSerilogEmailConnectionInfo();
return loggerConfiguration.Email(
emailConnectionInfo,
outputTemplate,
restrictedToMinimumLevel,
batchPostingLimit,
period,
formatProvider,
mailSubject);
}
@andriysavin My workaround for now is manually creating a config section for email logging (with credentials) and manually configuring the logging email sink with data from the custom config section. But it would be much more convenient to use the existing way of configuring an email sink, with the added properties 'username' and 'password'.
I meant that extension method would be called automatically so you don't have to write that manual code. Just as you would expect from out-of-the-box functionality. The only requirement is that your assembly contains Serilog in it's name or it's referenced explicitly in the config via Using.
I can tell that "port": 587
works for my project (netcoreapp2.1
) using
Serilog.Sinks.Email
v2.3.0
Serilog.Settings.Configuration
v3.0.1
For me, the "Port" and "EnableSsl" options are always set to 25 & false ... Any updates on this? "Serilog.AspNetCore" Version="3.4.0" "Serilog.Sinks.Email" Version="2.4.0"
For me, adding connectionInfo after args worked to configure port. But I can't seem to configure the network credentials:
"WriteTo": [
{
"Name": "Email",
"Args": {
"connectionInfo": {
"restrictedToMinimumLevel": "Warning",
"fromEmail": "email@email.co,",
"toEmail": "email@email.com",
"mailServer": "smtp.email.com",
"port": 587,
"networkCredentials": {
"UserName": "email@email.com",
"Password": "password"
}
}
}
}
]
}
3.0.0-dev-* now uses MailKit on all TFMs and will accept these through the regular configuration system. HTH! Closing this one as stale.
I am not being able to configure the network credentials and the port from the appsetting.json file. Follow the serilog section on my appsettings:
Any insight of how to configure this settings?
Thanks,