Sublogger Ignoring Events from Parent Logger
See original GitHub issueDoes this issue relate to a new feature or an existing bug?
- Bug
- New Feature
What version of Serilog is affected? Please list the related NuGet package. Serilog.AspNetCore 2.1.1
What is the target framework and operating system? See target frameworks & net standard matrix.
- netCore 2.0
- netCore 1.0
- 4.7
- 4.6.x
- 4.5.x
Please describe the current behavior? I set a Default MinimumLevel in my Serilog configuration of Debug, and override the MinumumLevel of one of my SourceContexts to “Verbose”. If I log directly to a Sink (File Sink, for example), it works as expected, with everything except the overridden source being filtered to Debug or higher, but Verbose events making it through for the overridden source. If I instead put a sub-logger between the main logger and the file sink (to add a filter or something), the Verbose events from the overridden source don’t make it through.
Here is a snippet from my appsettings.json configuration file:
"Serilog": {
"MinimumLevel": {
"Default": "Debug",
"Override": {
"System": "Information",
"Microsoft": "Information",
"Namespace.BenchmarkTimer": "Verbose"
}
},
"WriteTo": [
{
"Name": "Logger",
"Args": {
"configureLogger": {
"Filter": [
{
"Name": "ByIncludingOnly",
"Args": {
"expression": "StartsWith(SourceContext, 'Namespace.BenchmarkTimer')"
}
}
],
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "d:\\path-to-log-folder\\Benchmark Timer.txt"
}
}
]
}
}
}
]
},
Please describe the expected behavior? All of the events from the parent logger make it through to the sinks configured in the sub-logger.
If the current behavior is a bug, please provide the steps to reproduce the issue and if possible a minimal demo of the problem Configure an application as described above. Write verbose logs from SourceContext “Namespace.BenchmarkTimer”. The verbose events will not make it to the sub-logger’s configured File Sink.
Note: I did try setting restrictedToMinimumLevel to “Verbose” on the sub-logger, which didn’t make a difference.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (3 by maintainers)
@nblumhardt I’ll try to fix it 😃 I need this in my project 😉
@tsimbalar @maciejw this isn’t the same issue as #967, as far as I can tell.