serilog-settings-appsettings
serilog-settings-appsettings copied to clipboard
issue with NetworkCredentials
How to specify the networkCredential param using xml in Serilog.Sinks.Email. I try below but this cannot working
<add key="serilog:using:Email" value="Serilog.Sinks.Email"/>
<add key="serilog:write-to:Email.connectionInfo:emailSubject" value="Test log from Serilog"/>
<add key="serilog:write-to:Email.connectionInfo.fromEmail" value="[email protected]"/>
<add key="serilog:write-to:Email.connectionInfo:isBodyHtml" value="false"/>
<add key="serilog:write-to:Email.connectionInfo.mailServer" value="smtp.gmail.com"/>
<add key="serilog:write-to:Email.connectionInfo.networkCredentials.username" value="[email protected]"/>
<add key="serilog:write-to:Email.connectionInfo.networkCredentials.password" value="xxxxxxx"/>
<add key="serilog:write-to:Email.connectionInfo.toEmail" value="[email protected]"/>
<add key="serilog:write-to:Email.connectionInfo.port" value="587"/>
<add key="serilog:write-to:Email.outputTemplate" value="[{Timestamp:HH:mm:ss}];[{Level:u3}];{Message:lj}{NewLine}{Exception}"/>
<add key="serilog:write-to:Email.restrictedToMinimumLevel" value="Debug"/>
I have the same problem. Do you found the answer?
Long story short, you can't :-/
Serilog.Settings.AppSettings
does not do "complex" object creation.
This Stack Overflow question offers a workaround. In the example, this is a workaround for the JSON
settings, but you can do something similar, and then do this in your config :
<add key="serilog:write-to:EmailCustom.param1" value="Test log from Serilog"/>
<add key="serilog:write-to:EmailCustom.param2" value="Test log from Serilog"/>