api log to elastic

This commit is contained in:
Mikhail Trubnikov
2023-09-27 11:31:46 +10:00
parent feb2e79fc9
commit 00f5d9102a
4 changed files with 22 additions and 3 deletions

View File

@@ -19,6 +19,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" /> <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="Elastic.CommonSchema.Serilog" Version="8.6.1" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.5.2" /> <PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.5.2" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.5" /> <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">

View File

@@ -1,3 +1,4 @@
using Elastic.CommonSchema.Serilog;
using FluentValidation; using FluentValidation;
using PARR.API.Installers; using PARR.API.Installers;
using PARR.BLL; using PARR.BLL;
@@ -9,9 +10,12 @@ var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog((context, config) => builder.Host.UseSerilog((context, config) =>
{ {
config if (context.HostingEnvironment.IsProduction())
.WriteTo.Console() config.WriteTo.Console(new EcsTextFormatter());
.ReadFrom.Configuration(builder.Configuration); else
config.WriteTo.Console();
config.ReadFrom.Configuration(builder.Configuration);
}); });
// Add services to the container. // Add services to the container.

View File

@@ -5,6 +5,15 @@
"Microsoft.AspNetCore": "Debug" "Microsoft.AspNetCore": "Debug"
} }
}, },
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
},
"StorageSettings": { "StorageSettings": {
"StoragePath": "W:\\" "StoragePath": "W:\\"
}, },

View File

@@ -14,6 +14,11 @@ services:
#volumes: #volumes:
#- /var/log/parr-api:/app/log #- /var/log/parr-api:/app/log
#- parr_storage_dev:/app/Data #- parr_storage_dev:/app/Data
logging:
driver: fluentd
options:
fluentd-address: dvgd-mng-02.dvgd.oao.rzd:24224
tag: parr.api.serilog
deploy: deploy:
replicas: 2 replicas: 2