2018-01-11 11:20:38 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
2018-02-02 15:55:33 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2018-12-13 12:13:59 +01:00
|
|
|
|
using Serilog;
|
2018-01-11 11:20:38 +01:00
|
|
|
|
|
|
|
|
|
namespace OcelotApiGw
|
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
BuildWebHost(args).Run();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-02 15:55:33 +00:00
|
|
|
|
public static IWebHost BuildWebHost(string[] args)
|
|
|
|
|
{
|
2018-05-14 15:48:21 -07:00
|
|
|
|
IWebHostBuilder builder = WebHost.CreateDefaultBuilder(args);
|
2018-02-02 15:55:33 +00:00
|
|
|
|
builder.ConfigureServices(s => s.AddSingleton(builder))
|
2018-01-11 18:18:16 +01:00
|
|
|
|
.ConfigureAppConfiguration(ic => ic.AddJsonFile(Path.Combine("configuration", "configuration.json")))
|
2018-12-13 12:13:59 +01:00
|
|
|
|
.UseStartup<Startup>()
|
2019-02-28 11:40:11 +03:00
|
|
|
|
.ConfigureLogging((hostingContext, loggingbuilder) =>
|
|
|
|
|
{
|
|
|
|
|
loggingbuilder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
|
|
|
|
|
loggingbuilder.AddConsole();
|
|
|
|
|
loggingbuilder.AddDebug();
|
|
|
|
|
})
|
2018-12-13 12:13:59 +01:00
|
|
|
|
.UseSerilog((builderContext, config) =>
|
|
|
|
|
{
|
|
|
|
|
config
|
|
|
|
|
.MinimumLevel.Information()
|
|
|
|
|
.Enrich.FromLogContext()
|
|
|
|
|
.WriteTo.Console();
|
|
|
|
|
});
|
2018-05-14 15:48:21 -07:00
|
|
|
|
IWebHost host = builder.Build();
|
2018-02-02 15:55:33 +00:00
|
|
|
|
return host;
|
|
|
|
|
}
|
2018-01-11 11:20:38 +01:00
|
|
|
|
}
|
|
|
|
|
}
|