Skip to content

Commit 6e8bc17

Browse files
committed
fix: Logging configs are ignored when adding a filter using AddFilter<T>
1 parent 8262211 commit 6e8bc17

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

sandbox/SingleContainedAppWithConfig/appsettings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,14 @@
22
"AppConfig": {
33
"GlobalValue": "GLOBAL VALUE!!!!",
44
"EnvValue": "ENV VALUE!!!!"
5+
},
6+
"Logging": {
7+
"MicroBatchFramework.Logging.SimpleConsoleLoggerProvider": {
8+
"LogLevel": {
9+
"Default": "Trace",
10+
"System": "Information",
11+
"Microsoft": "Information"
12+
}
13+
}
514
}
615
}

src/MicroBatchFramework/BatchHost.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,20 @@ internal static void ConfigureLoggingDefault(IHostBuilder builder, bool useSimpl
103103
}
104104

105105
logging.AddSimpleConsole();
106-
logging.AddFilter<SimpleConsoleLoggerProvider>((category, level) =>
106+
logging.AddFilter((providerName, category, level) =>
107107
{
108-
// omit system message
109-
if (category.StartsWith("Microsoft.Extensions.Hosting.Internal"))
108+
if (providerName == typeof(SimpleConsoleLogger).FullName)
110109
{
111-
if (level <= LogLevel.Debug) return false;
110+
// omit system message
111+
if (category.StartsWith("Microsoft.Extensions.Hosting.Internal"))
112+
{
113+
if (level <= LogLevel.Debug) return false;
114+
}
115+
116+
return level >= minSimpleConsoleLoggerLogLevel;
112117
}
113118

114-
return level >= minSimpleConsoleLoggerLogLevel;
119+
return true;
115120
});
116121
});
117122
}

0 commit comments

Comments
 (0)