44 lines
1.3 KiB
C#
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");
|
|
});
|
|
}
|
|
}
|