I just got started with Serilog. I started out a very simple configuration, but I can't confirm it's loaded...maybe I am not looking into the right place?
appsettings (snippet):
"Serilog": {
"Using": [ "Serilog", "Serilog.Sinks.Console", "Serilog.Sinks.EventLog" ],
"MinimumLevel": {
"Default": "Debug"
}
program.cs
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(
(hostingContext, config) =>
configureConfiguration(hostingContext, config))
.UseSerilog(
(hostingContext, config) =>
configureSeriLog(hostingContext, config));
// local function
void configureSeriLog(HostBuilderContext cntxt, LoggerConfiguration builder)
{
builder.ReadFrom
.Configuration(cntxt.Configuration);
}
I set a breakpoint at the ReadFrom.Configuration() call. After the call is made, I look at the non-Public members _minimumLevel under the builder variable and it says Information. Am I looking at the wrong spot or the configuration wasn't loaded. Thanks a million!
To diagnose issues, you can try using the SelfLog
Serilog.Debugging.SelfLog.Enable(x => Debug.WriteLine(x));
When Serilog is not behaving as you expect, this may be caused by an internal exception or configuration issue. Here are a couple of ways to sort things out.
...