AddEnvironmentVariables fix

master
Tudor Stanciu 2021-11-14 11:40:19 +02:00
parent 958a8499f8
commit 3757a25ed1
1 changed files with 6 additions and 1 deletions

View File

@ -27,6 +27,7 @@ namespace IdentityServer.Api
var configuration = new ConfigurationBuilder() var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory()) .SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddEnvironmentVariables()
.Build(); .Build();
var connectionString = configuration.GetConnectionString("DatabaseConnection"); var connectionString = configuration.GetConnectionString("DatabaseConnection");
@ -42,14 +43,18 @@ namespace IdentityServer.Api
var mssqlSinkOptions = new MSSqlServerSinkOptions() { AutoCreateSqlTable = true, TableName = "__Logs" }; var mssqlSinkOptions = new MSSqlServerSinkOptions() { AutoCreateSqlTable = true, TableName = "__Logs" };
Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine(msg));
Log.Logger = new LoggerConfiguration() Log.Logger = new LoggerConfiguration()
.MinimumLevel.ControlledBy(loggingLevelSwitch) .MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.Enrich.FromLogContext() .Enrich.FromLogContext()
.WriteTo.Console() .WriteTo.Console()
.WriteTo.MSSqlServer(connectionString, mssqlSinkOptions, columnOptions: columnOptions) .WriteTo.MSSqlServer(connectionString, mssqlSinkOptions, columnOptions: columnOptions)
.CreateLogger(); .CreateLogger();
Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine(msg));
try try
{ {
var urls = configuration.GetValue<string>("urls"); var urls = configuration.GetValue<string>("urls");