serilog / serilog-sinks-email

A Serilog sink that writes events to SMTP email
Apache License 2.0
73 stars 68 forks source link

Unable to use appsetting to configure credentials for email send #76

Open pcharb opened 4 years ago

pcharb commented 4 years ago

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.

brunis commented 4 years ago

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?

KrzysztofPajak commented 4 years ago

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

brunis commented 4 years ago

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..

FransdeJong commented 4 years ago

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