I just opened Serylogue and I like it. However, I'm struggling to read it from app.config.
Code Configuration:
ILogger logger = new LoggerConfiguration()
.ReadFrom.AppSettings()
//.MinimumLevel.Verbose()
.Enrich.WithProcessId()
.Enrich.WithThreadId()
.Enrich.WithMachineName()
.Destructure.UsingAttributes()
//.WriteTo.MSSqlServer(@"Server=EVDVWADBV1;Database=AppLog;Trusted_Connection=True;", "Logs")
.CreateLogger();
Log.Logger = logger;
Commented sections are the configuration values that I want to read from the configuration file.
The configuration file contains:
<appSettings>
<add key="serilog:minimum-level" value="Verbose"/>
<add key="serilog:using" value="Serilog.Sinks.MSSqlServer"/>
<add key="serilog:write-to:MSSqlServer.connectionString" value="Server=EVDVWADBV1;Database=AppLog;Trusted_Connection=True;"/>
<add key="serilog:writeto:MSSqlServer.tableName" value="Logs"/>
<add key="serilog:write-to:RollingFile.pathFormat" value="C:\Logs\myapp-{Date}.txt" />
<add key="serilog:write-to:RollingFile.retainedFileCountLimit" value="10" />
</appSettings>
I use the following Serilog packages.
<package id="Serilog" version="1.5.14" targetFramework="net452" />
<package id="Serilog.Sinks.MSSqlServer" version="3.0.41" targetFramework="net452" />
I also added this as the first line of my console application. I do not see any errors on the console.
Serilog.Debugging.SelfLog.Out = Console.Out;
What am I missing?
source
share