From 54e0675ba923325735517bf26f82a197bd4a857a Mon Sep 17 00:00:00 2001 From: Masu-Baumgartner <68913099+Masu-Baumgartner@users.noreply.github.com> Date: Tue, 29 Oct 2024 09:22:05 +0100 Subject: [PATCH] Improved default log level definition --- Moonlight.ApiServer/Startup.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Moonlight.ApiServer/Startup.cs b/Moonlight.ApiServer/Startup.cs index 8a291170..77669c74 100644 --- a/Moonlight.ApiServer/Startup.cs +++ b/Moonlight.ApiServer/Startup.cs @@ -38,8 +38,15 @@ public static class Startup // Ensure logging config, add a default one is missing if (!File.Exists(logConfigPath)) { - await File.WriteAllTextAsync(logConfigPath, - "{\"LogLevel\":{\"Default\":\"Information\",\"Microsoft.AspNetCore\":\"Warning\",\"MoonCore.Extended.Helpers.JwtHelper\": \"Error\"}}"); + var logLevels = new Dictionary + { + { "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));