39 lines
1.4 KiB
C#
39 lines
1.4 KiB
C#
using System.Net;
|
|
using NLog.Extensions.Logging;
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace ChaosBot.WebServer
|
|
{
|
|
public static class WebServer
|
|
{
|
|
public static void Start(string[] args)
|
|
{
|
|
CreateHostBuilder(args).Build().Run();
|
|
}
|
|
|
|
private static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
Host.CreateDefaultBuilder(args)
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
{
|
|
webBuilder.ConfigureKestrel(serverOptions =>
|
|
{
|
|
serverOptions.Listen(IPAddress.Any, Program.AppSettingsHandler.GetValue<int>("WebServer:Port"),
|
|
listenOptions =>
|
|
{
|
|
listenOptions.UseConnectionLogging();
|
|
});
|
|
})
|
|
.ConfigureLogging(logging =>
|
|
{
|
|
logging.ClearProviders();
|
|
logging.SetMinimumLevel(LogLevel.Trace);
|
|
logging.AddNLog(new NLogLoggingConfiguration(Program.AppSettingsHandler.GetSection("NLog")));
|
|
})
|
|
.UseStartup<Startup>();
|
|
});
|
|
}
|
|
} |