исправления

This commit is contained in:
Роман Пермяков 2024-05-06 15:47:54 +04:00
parent a6f83930f9
commit c34c2b42a0
3 changed files with 31 additions and 8 deletions

View File

@ -9,6 +9,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />

View File

@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Events;
namespace AccordionBus
{
@ -24,14 +26,14 @@ namespace AccordionBus
private static void ConfigureServices(ServiceCollection services)
{
services.AddSingleton<FormBusCollection>()
.AddLogging(option => option.AddSerilog(dispose: true));
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.File("C:\\my\\êóðñ 1 ñèì 2\\äëÿ ÎÎÏ\\log.txt")
.CreateLogger();
.AddLogging(option => {
option.SetMinimumLevel(LogLevel.Debug);
option.AddSerilog(new LoggerConfiguration()
.ReadFrom.Configuration(new ConfigurationBuilder()
.AddJsonFile("C:\\my\\êóðñ 1 ñèì 2\\äëÿ ÎÎÏ\\simple\\AccordionBus\\AccordionBus\\serilog.json")
.Build())
.CreateLogger());
});
}
}
}

View File

@ -0,0 +1,18 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "C:\\my\\курс 1 сим 2\\для ООП\\log.txt",
"outputTemplate": "[{Level:u}] [{Timestamp:yyyy-MM-dd HH:mm:ss.ffff}] {Message:1j}{NewLine}{Exception}"
}
}
],
"Properties": {
"Application": "Sample"
}
}
}