Налаживание стандартного оформления логов.
This commit is contained in:
parent
15553c9fdd
commit
46569d56d3
@ -41,6 +41,7 @@
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -30,21 +30,18 @@ namespace Airbus
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<FormMapWithSetPlanes>()
|
||||
.AddLogging(option =>
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile(path: "C:\\Users\\Programmist73\\Desktop\\Ïðàêòèêà\\2-é êóðñ\\ÐÏÏ\\Base\\PIbd-21_Eliseev_E.E._Airbus_Base\\Airbus\\Airbus\\appsettings.json", optional: false, reloadOnChange: true)
|
||||
.Build();
|
||||
services.AddSingleton<FormMapWithSetPlanes>();
|
||||
|
||||
var logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(configuration)
|
||||
var serilogLogger = new LoggerConfiguration()
|
||||
.WriteTo.RollingFile("Logs\\log.txt")
|
||||
.CreateLogger();
|
||||
|
||||
services.AddLogging(option =>
|
||||
{
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddSerilog(logger);
|
||||
option.AddSerilog(logger: serilogLogger, dispose: true);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": "Information",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/log_.log",
|
||||
"rollingInterval": "Day",
|
||||
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
|
||||
"Destructure": [
|
||||
{
|
||||
"Name": "ByTransforming",
|
||||
"Args": {
|
||||
"returnType": "Plane.EntityAirbus",
|
||||
"transformation": "r => new { BodyColor = r.BodyColor.Name, r.Speed, r.Weight }"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "ByTransforming",
|
||||
"Args": {
|
||||
"returnType": "Plane.EntitySuperAirbus",
|
||||
"transformation": "r => new { BodyColor = r.BodyColor.Name, DopColor = r.DopColor.Name, r.HasСompartment, r.HasEngine, r.Speed, r.Weight }"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "ToMaximumDepth",
|
||||
"Args": { "maximumDestructuringDepth": 4 }
|
||||
},
|
||||
{
|
||||
"Name": "ToMaximumStringLength",
|
||||
"Args": { "maximumStringLength": 100 }
|
||||
},
|
||||
{
|
||||
"Name": "ToMaximumCollectionCount",
|
||||
"Args": { "maximumCollectionCount": 10 }
|
||||
}
|
||||
],
|
||||
"Properties": {
|
||||
"Application": "Airbus"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user