This repository has been archived on 2023-02-13. You can view files and clone it, but cannot push or open issues or pull requests.
gswi-server/gswi/Program.cs
2022-02-20 19:04:11 +01:00

44 lines
1.3 KiB
C#

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using gswi.Configuration;
using System;
namespace gswi
{
public class Program
{
static void Main(string[] args)
{
try
{
Configuration.HostExtensions.ChangeCurrentDirToProjectDir();
var host = CreateHostBuilder(args).Build();
host.LogHostingEnvironment<Program>();
host.SeedData();
host.Run();
}
catch (Exception ex)
{
Configuration.HostExtensions.LogStartError(ex);
Console.WriteLine(ex.ToString());
}
finally
{
NLog.LogManager.Shutdown();
}
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
}).ConfigureLogging((hostCtx, loggingBuilder) =>
{
loggingBuilder.SetMinimumLevel(LogLevel.Trace);
loggingBuilder.AddNLog($"nlog-{hostCtx.HostingEnvironment.EnvironmentName}.config");
});
}
}