How to use Serilog with Unity in appsettings

721 Views Asked by At

I would like to define with Unity framework inside the web.config using <constructor> tag, the equivalent of executing this code:

    ILogger log = new LoggerConfiguration()
                    .ReadFrom.AppSettings()
                    .CreateLogger();

but inside the web.config.. something like this:

    <type type="ILogger" name="serilog" mapTo="Serilog, Serilog.Logging">
        <lifetime type="singleton" />
        <typeConfig extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement, Microsoft.Practices.Unity.Configuration">
            <constructor>
                ///read from appsettings.
            </constructor>
        </typeConfig>
    </type>

and then

<appSettings>
    <add key="serilog:minimum-level" value="Verbose" />
</appSettings>

I cannot find any example for calling the sink methods with unity inside a web.config. Can any body help me?

0

There are 0 best solutions below