Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with NetworkCredentials #38

Open
viettd1190 opened this issue Jun 13, 2019 · 2 comments
Open

issue with NetworkCredentials #38

viettd1190 opened this issue Jun 13, 2019 · 2 comments

Comments

@viettd1190
Copy link

viettd1190 commented Jun 13, 2019

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"/>
@Michael-Borges
Copy link

I have the same problem. Do you found the answer?

@tsimbalar
Copy link
Member

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"/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants