54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using NLog.Web;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BlaServApp.UI
|
|
{
|
|
public class Program
|
|
{
|
|
#region Public Methods
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
Host.CreateDefaultBuilder(args)
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
{
|
|
webBuilder.UseStartup<Startup>();
|
|
})
|
|
.ConfigureLogging(logging =>
|
|
{
|
|
logging.ClearProviders();
|
|
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
|
|
})
|
|
.UseNLog();
|
|
|
|
public static void Main(string[] args)
|
|
{
|
|
// inclusione NLog:
|
|
// https://github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-5
|
|
// https://codewithmukesh.com/blog/logging-with-nlog-in-aspnet-core/
|
|
var logger = NLog.Web.NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger();
|
|
try
|
|
{
|
|
logger.Info("GMWS.UI Application Starting Up");
|
|
CreateHostBuilder(args).Build().Run();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
logger.Error(exception, "Stopped GMWS.UI program because of exception");
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
NLog.LogManager.Shutdown();
|
|
}
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |