all logs send to elastic
This commit is contained in:
@@ -1,18 +1,24 @@
|
||||
using Elastic.CommonSchema.Serilog;
|
||||
using PARR.GeneratorTemplates;
|
||||
using PARR.GeneratorTemplatesWorker;
|
||||
using Serilog;
|
||||
|
||||
|
||||
var builder = Host.CreateApplicationBuilder();
|
||||
|
||||
builder.Services.AddLogging(config =>
|
||||
{
|
||||
config.ClearProviders();
|
||||
var logger = new LoggerConfiguration()
|
||||
.WriteTo.Console()
|
||||
.ReadFrom.Configuration(builder.Configuration)
|
||||
.CreateLogger();
|
||||
config.AddSerilog(logger);
|
||||
|
||||
var logger = new LoggerConfiguration();
|
||||
|
||||
if (builder.Environment.IsProduction())
|
||||
logger.WriteTo.Console(new EcsTextFormatter());
|
||||
else
|
||||
logger.WriteTo.Console();
|
||||
|
||||
logger.ReadFrom.Configuration(builder.Configuration);
|
||||
|
||||
config.AddSerilog(logger.CreateLogger());
|
||||
});
|
||||
|
||||
builder.Services.InstallGeneratorTemplateServices(builder.Configuration);
|
||||
@@ -23,40 +29,3 @@ builder.Services.AddHostedService<Worker>();
|
||||
|
||||
var host = builder.Build();
|
||||
host.Run();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//IHost host = Host.CreateDefaultBuilder(args)
|
||||
// .ConfigureServices((hostContext, services) =>
|
||||
// {
|
||||
// services.InstallGeneratorTemplateServices(hostContext.Configuration);
|
||||
// //hostContext.Configuration.AddGeneratorTemplateConfigurations(services);
|
||||
// //services.AddGeneratorTemplateSettings(hostContext.Configuration);
|
||||
|
||||
// //services.AddHostedService<Worker>();
|
||||
// })
|
||||
// .ConfigureAppConfiguration((hostContext, configBuilder) =>
|
||||
// {
|
||||
// //TODO: !!!!!!!!!не смог прикрутить AddGeneratorTemplateConfigurations, не могу прокинуть туда сервисы
|
||||
// configBuilder.AddGeneratorTemplateConfigurations(hostContext.Services);
|
||||
// })
|
||||
// .ConfigureServices((hostContext, services) =>
|
||||
// {
|
||||
// services.AddGeneratorTemplateSettings(hostContext.Configuration);
|
||||
|
||||
// services.AddHostedService<Worker>();
|
||||
// })
|
||||
// .UseSerilog((hostContext, services, config) =>
|
||||
// {
|
||||
// config
|
||||
// .WriteTo.Console()
|
||||
// .ReadFrom.Configuration(hostContext.Configuration);
|
||||
// })
|
||||
// .Build();
|
||||
|
||||
//host.Run();
|
||||
|
||||
Reference in New Issue
Block a user