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>
<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="Microsoft.AspNetCore.OpenApi" 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 PARR.API.Installers;
using PARR.BLL;
@@ -9,9 +10,12 @@ var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog((context, config) =>
{
config
.WriteTo.Console()
.ReadFrom.Configuration(builder.Configuration);
if (context.HostingEnvironment.IsProduction())
config.WriteTo.Console(new EcsTextFormatter());
else
config.WriteTo.Console();
config.ReadFrom.Configuration(builder.Configuration);
});
// Add services to the container.

View File

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