serilog-sinks-email icon indicating copy to clipboard operation
serilog-sinks-email copied to clipboard

Unable to use appsetting to configure credentials for email send

Open pcharb opened this issue 6 years ago • 5 comments

When I try to use serilogs appconfig to set up my sinks email, the network credentials are not being used

Here is my config

<add key="serverUrl" value="localhost"/>
<add key="serilog:using:Email" value="Serilog.Sinks.Email" />
<add key="serilog:write-to:Email.fromEmail" value="emailfrom"/>
<add key="serilog:write-to:Email.toEmail" value="emailto" />
<add key="serilog:write-to:Email.mailServer" value="in-v3.mailjet.com" />

<add key="serilog:enrich:with-property:environment" value="Localhost" />
<add key="serilog:write-to:Email.port" value="587"/>
<add key="serilog:write-to:Email.networkCredentials" value="'username':'username' 'password':'password'"/>

<add key="serilog:write-to:Email.EnableSsl" value="true"/>
<add key="serilog:write-to:Email.mailSubject" value="[{environment} - {MachineName}]" />
<add key="serilog:write-to:Email.outputTemplate" value="{Timestamp:yyyy-MM-dd  HH:mm:ss}:: [{SourceContext} {NewLine}{Level:u3} - {Message:lj}{NewLine}{Exception}{SourceContext}]" />
<add key="serilog:write-to:Email.restrictedToMinimumLevel" value="Error" />

I'm unable to find any documentation on what i,m doing wrong. The issue might be more of a documentation issue.

pcharb avatar Dec 06 '19 18:12 pcharb

I have the same problem, no docs or explanation for how to configure this sink through AppSettings. I tried using

<add key="serilog:write-to:Email.networkCredentials.UserName" value="username"/>
<add key="serilog:write-to:Email.networkCredentials.Password" value="password"/>

Also, no luck. @pcharb did you manage to solve it?

brunis avatar Jun 17 '20 09:06 brunis

Any news? It would be great if this problem will be resolved?

KrzysztofPajak avatar Jul 09 '20 09:07 KrzysztofPajak

Any news? It would be great if this problem will be resolved?

We ended up using our own configuration entries to set it up. Seems it's only configurable through appsettings.json for now..

brunis avatar Jul 09 '20 11:07 brunis

@brunis are you using this in core or framework? I'm using Umbraco and .Net Framework so I don't have a appsettings.json

FransdeJong avatar Jul 13 '20 10:07 FransdeJong