This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.Hosting; | |
using Microsoft.Extensions.Logging; | |
using Microsoft.Extensions.Logging.ApplicationInsights; | |
using Notifier.Common.Extensions; | |
using Notifier.Common.Settings; | |
namespace Notifier.WebApi | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
CreateHostBuilder(args).Build().Run(); | |
} | |
public static IHostBuilder CreateHostBuilder(string[] args) => | |
Host.CreateDefaultBuilder(args) | |
.ConfigureAppConfiguration((hostBuilderContext, builder) => | |
{ | |
// Add configuration file, environment variables and command line arguments | |
builder | |
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) | |
.AddUserSecrets(typeof(Program).Assembly, false) | |
.AddEnvironmentVariables() | |
.AddCommandLine(args); | |
}) | |
.ConfigureLogging((context, builder) => | |
{ | |
builder.AddConfiguration(context.Configuration.GetSection(nameof(LoggingSettings))); | |
builder.AddConsole(); | |
builder.AddFilter<ApplicationInsightsLoggerProvider>( | |
"", | |
Microsoft.Extensions.Logging.LogLevel.Information); // this will capture Info level traces and above. | |
}) | |
.ConfigureWebHostDefaults(webBuilder => | |
{ | |
// Configure kestrel web server and call startup. | |
webBuilder | |
.ConfigureKestrel(serverOptions => | |
{ | |
serverOptions.Listen(IPAddress.Any, 8080); | |
// Needed because of using newtonsoft json | |
// (else there are performance issues in .net core 3) | |
serverOptions.AllowSynchronousIO = true; | |
}) | |
.UseStartup<Startup>(); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment