C
C#7mo ago
WEIRD FLEX

✅ how do logging settings work

i'm trying to change logging settings for another issue, but they doesn't seem to be intuitive or really not even to work like the docs say shouldn't this filter almost everything?
{
"Logging": {
"Serilog": {
"IncludeScopes": true
},
"LogLevel": {
"Default": "Warning"
}
},
"Serilog": {
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
}
]
},
}
{
"Logging": {
"Serilog": {
"IncludeScopes": true
},
"LogLevel": {
"Default": "Warning"
}
},
"Serilog": {
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
}
]
},
}
instead i see even debug logs there are no other settings (like other appsettings or environment variables) it would be really nice if for once i didn't have to look at the source code to understand how it works
7 Replies
WEIRD FLEX
WEIRD FLEX7mo ago
hmm should Serilog have the priority over .net? https://learn.microsoft.com/en-us/dotnet/core/extensions/logging doc says it filters the logs before sending them to the provider
Logging in C# - .NET
Learn about app logging provided by the Microsoft.Extensions.Logging NuGet package in C#.
cap5lut
cap5lut7mo ago
the log providers there are just the different sinks. not serilog itself, which is the logging framework and thus needs its own configuration with ur configuration i would guess that the internal flow would be from ILogger to MS.E.Logging as framework to a sink that passes it to the Serilog framework which passes it to Serilog's Console sink but u probably have set up serilog in the way that its logger factory will be used, so its just their implementations using the MS.E.Logging interfaces thus the flow would be from ILogger to Serilog as framework to Serilog's Console sink and thus the MS.E.Logging configuration isnt even looked at
WEIRD FLEX
WEIRD FLEX7mo ago
i didn't set it up, that's the problem also in the middle there is abp i can tell you there is this
builder.AddProvider(new SerilogLoggerProvider(logger));
builder.AddFilter<SerilogLoggerProvider>(null, LogLevel.Trace);
builder.AddProvider(new SerilogLoggerProvider(logger));
builder.AddFilter<SerilogLoggerProvider>(null, LogLevel.Trace);
and that at least some of these do work
{
"Logging": {
"Serilog": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Information",
"Microsoft": "Debug",
}
{
"Logging": {
"Serilog": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Information",
"Microsoft": "Debug",
}
but not enough to have an evident causality maybe just "Default" is being ignored i dont f know yeah anyway is something that has to do with two logging frameworks fighting
cap5lut
cap5lut7mo ago
well, did u try setting up the logging only via serilog as in the linked tutorial?
WEIRD FLEX
WEIRD FLEX7mo ago
yes, sure although in tens of configurations for clients we have never used levels inside the serilog section
cap5lut
cap5lut7mo ago
serilog states here as well, that its read from the Serilog section, i would assume that its not from within the Logging section https://github.com/serilog/serilog-settings-configuration#serilogsettingsconfiguration--