Improved default log level definition

This commit is contained in:
Masu-Baumgartner
2024-10-29 09:22:05 +01:00
parent e02af774a9
commit 54e0675ba9

View File

@@ -38,8 +38,15 @@ public static class Startup
// Ensure logging config, add a default one is missing // Ensure logging config, add a default one is missing
if (!File.Exists(logConfigPath)) if (!File.Exists(logConfigPath))
{ {
await File.WriteAllTextAsync(logConfigPath, var logLevels = new Dictionary<string, string>
"{\"LogLevel\":{\"Default\":\"Information\",\"Microsoft.AspNetCore\":\"Warning\",\"MoonCore.Extended.Helpers.JwtHelper\": \"Error\"}}"); {
{ "Default", "Information" },
{ "Microsoft.AspNetCore", "Warning" }
};
var logLevelsJson = JsonSerializer.Serialize(logLevels);
var logConfig = "{\"LogLevel\":" + logLevelsJson + "}";
await File.WriteAllTextAsync(logConfigPath, logConfig);
} }
builder.Logging.AddConfiguration(await File.ReadAllTextAsync(logConfigPath)); builder.Logging.AddConfiguration(await File.ReadAllTextAsync(logConfigPath));