mirror of https://github.com/abpframework/abp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.2 KiB
68 lines
2.2 KiB
using System;
|
|
using System.IO;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.InProcess;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Serilog;
|
|
using Serilog.Events;
|
|
using Serilog.Sinks.Elasticsearch;
|
|
|
|
namespace BackendAdminApp.Host
|
|
{
|
|
public class Program
|
|
{
|
|
public static int Main(string[] args)
|
|
{
|
|
CurrentDirectoryHelpers.SetCurrentDirectory();
|
|
|
|
//TODO: Temporary: it's not good to read appsettings.json here just to configure logging
|
|
var configuration = new ConfigurationBuilder()
|
|
.SetBasePath(Directory.GetCurrentDirectory())
|
|
.AddJsonFile("appsettings.json")
|
|
.AddEnvironmentVariables()
|
|
.Build();
|
|
|
|
Log.Logger = new LoggerConfiguration()
|
|
.MinimumLevel.Debug()
|
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
|
.Enrich.WithProperty("Application", "BackendAdminApp")
|
|
.Enrich.FromLogContext()
|
|
.WriteTo.File("Logs/logs.txt")
|
|
.WriteTo.Elasticsearch(
|
|
new ElasticsearchSinkOptions(new Uri(configuration["ElasticSearch:Url"]))
|
|
{
|
|
AutoRegisterTemplate = true,
|
|
AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv6,
|
|
IndexFormat = "msdemo-log-{0:yyyy.MM}"
|
|
})
|
|
.CreateLogger();
|
|
|
|
try
|
|
{
|
|
Log.Information("Starting BackendAdminApp.Host.");
|
|
BuildWebHostInternal(args).Run();
|
|
return 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Fatal(ex, "BackendAdminApp.Host terminated unexpectedly!");
|
|
return 1;
|
|
}
|
|
finally
|
|
{
|
|
Log.CloseAndFlush();
|
|
}
|
|
}
|
|
|
|
public static IWebHost BuildWebHostInternal(string[] args) =>
|
|
new WebHostBuilder()
|
|
.UseKestrel()
|
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
|
.UseIIS()
|
|
.UseIISIntegration()
|
|
.UseStartup<Startup>()
|
|
.UseSerilog()
|
|
.Build();
|
|
}
|
|
}
|