diff --git a/dependencies.props b/dependencies.props index ec53fe9..6f93ade 100644 --- a/dependencies.props +++ b/dependencies.props @@ -1,10 +1,10 @@ - 3.1.3 - 3.2.0 - 3.0.1 - 3.1.1 - 5.2.0 + 3.1.8 + 4.1.0 + 3.1.0 + 4.0.0 + 5.6.1 9.0.0 7.0.0 6.0.0 diff --git a/src/api/NetworkResurrector.Api/Program.cs b/src/api/NetworkResurrector.Api/Program.cs index 1929c94..d3a1b2d 100644 --- a/src/api/NetworkResurrector.Api/Program.cs +++ b/src/api/NetworkResurrector.Api/Program.cs @@ -33,19 +33,25 @@ namespace NetworkResurrector.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(); columnOptions.Store.Remove(StandardColumn.Properties); columnOptions.Store.Remove(StandardColumn.MessageTemplate); columnOptions.Store.Add(StandardColumn.LogEvent); + + var mssqlSinkOptions = new MSSqlServerSinkOptions() { AutoCreateSqlTable = true, TableName = "__Logs" }; + Log.Logger = new LoggerConfiguration() .MinimumLevel.ControlledBy(loggingLevelSwitch) .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) .Enrich.FromLogContext() .WriteTo.Console() - .WriteTo.MSSqlServer(connectionString, "__Logs", autoCreateSqlTable: true, columnOptions: columnOptions) + .WriteTo.MSSqlServer(connectionString, mssqlSinkOptions, columnOptions: columnOptions) .CreateLogger(); try diff --git a/src/server/NetworkResurrector.Server/Program.cs b/src/server/NetworkResurrector.Server/Program.cs index 5dbd226..ef00d5a 100644 --- a/src/server/NetworkResurrector.Server/Program.cs +++ b/src/server/NetworkResurrector.Server/Program.cs @@ -33,19 +33,25 @@ namespace NetworkResurrector.Server 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(); columnOptions.Store.Remove(StandardColumn.Properties); columnOptions.Store.Remove(StandardColumn.MessageTemplate); columnOptions.Store.Add(StandardColumn.LogEvent); + + var mssqlSinkOptions = new MSSqlServerSinkOptions() { AutoCreateSqlTable = true, TableName = "__Logs" }; + Log.Logger = new LoggerConfiguration() .MinimumLevel.ControlledBy(loggingLevelSwitch) .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) .Enrich.FromLogContext() .WriteTo.Console() - .WriteTo.MSSqlServer(connectionString, "__Logs", autoCreateSqlTable: true, columnOptions: columnOptions) + .WriteTo.MSSqlServer(connectionString, mssqlSinkOptions, columnOptions: columnOptions) .CreateLogger(); try