44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using NLog;
|
|
using NLog.Web;
|
|
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
|
|
|
|
namespace Web
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var logger = LogManager/*NLogBuilder/*.ConfigureNLog("nlog.config")*/.GetCurrentClassLogger();
|
|
try
|
|
{
|
|
logger.Debug("init main");
|
|
CreateHostBuilder(args).Build().Run();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
//NLog: catch setup errors
|
|
logger.Fatal(exception, "Program stopped due to exception");
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
NLog.LogManager.Shutdown();
|
|
}
|
|
}
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
Host.CreateDefaultBuilder(args)
|
|
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); })
|
|
.ConfigureLogging(logging =>
|
|
{
|
|
// prefer NLog for logging
|
|
//logging.ClearProviders();
|
|
logging.SetMinimumLevel(LogLevel.Trace);
|
|
})
|
|
.UseNLog();
|
|
}
|
|
} |