|
|
|
@ -1,8 +1,10 @@ |
|
|
|
using System; |
|
|
|
using System.IO; |
|
|
|
using Microsoft.AspNetCore.Hosting; |
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
using Serilog; |
|
|
|
using Serilog.Events; |
|
|
|
using Serilog.Sinks.Elasticsearch; |
|
|
|
|
|
|
|
namespace BackendAdminAppGateway.Host |
|
|
|
{ |
|
|
|
@ -10,11 +12,26 @@ namespace BackendAdminAppGateway.Host |
|
|
|
{ |
|
|
|
public static int Main(string[] args) |
|
|
|
{ |
|
|
|
//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", "BackendAdminAppGateway") |
|
|
|
.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 |
|
|
|
|