From aae5a3523febd15f11defb68d3082f019d1079f9 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Sun, 5 Dec 2021 22:40:13 +0200 Subject: [PATCH] fix --- IdentityServer.Api/Program.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/IdentityServer.Api/Program.cs b/IdentityServer.Api/Program.cs index 1c06f7a..68c1918 100644 --- a/IdentityServer.Api/Program.cs +++ b/IdentityServer.Api/Program.cs @@ -33,7 +33,10 @@ namespace IdentityServer.Api var connectionString = configuration.GetConnectionString("DatabaseConnection"); var loggingLevelParam = configuration.GetValue("Logging:LogLevel:Default"); - Enum.TryParse(loggingLevelParam, out LogEventLevel loggingLevel); + var loggingLevelOk = Enum.TryParse(loggingLevelParam, out LogEventLevel loggingLevel); + if (!loggingLevelOk) + throw new Exception($"Logging level '{loggingLevelParam}' is not valid."); + var loggingLevelSwitch = new LoggingLevelSwitch(loggingLevel); var columnOptions = new ColumnOptions(); @@ -43,17 +46,15 @@ namespace IdentityServer.Api var mssqlSinkOptions = new MSSqlServerSinkOptions() { AutoCreateSqlTable = true, TableName = "__Logs" }; - Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine(msg)); - Log.Logger = new LoggerConfiguration() - .MinimumLevel.Verbose() + .MinimumLevel.ControlledBy(loggingLevelSwitch) .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) .Enrich.FromLogContext() .WriteTo.Console() .WriteTo.MSSqlServer(connectionString, mssqlSinkOptions, columnOptions: columnOptions) .CreateLogger(); - Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine(msg)); + //Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine(msg)); try {