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

Add support for 'Destructure' configuration options in app settings #20

Closed
olamartensson opened this issue Jan 31, 2018 · 5 comments
Closed

Comments

@olamartensson
Copy link

olamartensson commented Jan 31, 2018

I would like to be able to configure Serilog's Destructure configuration options like e.g.:

Log.Logger = new LoggerConfiguration()
                .Destructure.With<MyCustomDestructuringPolicy>()
                .Destructure.UsingAttributes() // using Destructurama.Attributed
                .CreateLogger();

in the app settings XML file like e.g.:

<appSettings>
    <add key="serilog:using:DestructuringPolicies" value="MyApp.CustomDestructuringPolicies" />
    <add key="serilog:destructure:WithMyCustomDestructuringPolicy" />
    <add key="serilog:using:Destructurama" value="Destructurama.Attributed" />
    <add key="serilog:destructure:UsingAttributes" />
</appSettings>

It seems to me this is not possible today.

@olamartensson olamartensson changed the title Add support for Destructure configuration options in app settings Add support for Destructure configuration options in app settings Jan 31, 2018
@olamartensson olamartensson changed the title Add support for Destructure configuration options in app settings Add support for 'Destructure' configuration options in app settings Jan 31, 2018
@nblumhardt
Copy link
Member

Thanks for the suggestion 👍

@tsimbalar
Copy link
Member

In order to have aconsistent implementation, it should be similar to serilog/serilog-settings-configuration#110

@tsimbalar
Copy link
Member

How should generic parameters be specified in order to call .Destructure.With<MyCustomDestructuringPolicy>() ?

I would say staying close to C# would be the best approach (using angle brackets), but in a XML-ish config file, that probably means they would have to be escaped like so :

    <add key="serilog:using:DestructuringPolicies" value="MyApp.CustomDestructuringPolicies" />
    <add key="serilog:destructure:With&lt;MyCustomDestructuringPolicy&gt;" />

Another option is to not support generic parameters at all in the settings providers, but to add a non-generic version of the method in Serilog and having both :

public LoggerConfiguration With<TDestructuringPolicy>()

and

public LoggerConfiguration With(Type destructuringPolicyType)

The first one can be used in C# code, the second one can be used in configuration (I believe there is already support for parameters of type Type, but I may be wrong ...).

@nblumhardt
Copy link
Member

Looks like this has moved forwards 👍

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