Reputation: 599
How can I make LoggerConfiguration is manage via Web.config (appsetting) such as Verbose/Debug etc.
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()// I want to make is configurable via web.config.
.Enrich.FromLogContext()
.WriteTo.Seq(serilogUrl)
.CreateLogger();
Upvotes: 1
Views: 2629
Reputation: 2996
You have to use the library that @C. Augusto Proiete linked (Serilog.Settings.AppSettings).
There is a good documentation with examples on this this page.
Upvotes: 0
Reputation: 27908
Use Serilog.Settings.AppSettings
Log.Logger = new LoggerConfiguration()
.ReadFrom.AppSettings()
... // Other configuration here, then
.CreateLogger();
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="serilog:minimum-level" value="Verbose" />
<!-- More settings here -->
</appSettings>
</configuration>
Serilog's documentation is quite good. You should check it out: https://serilog.net
Upvotes: 3