Лабораторная работа №7 сделана

This commit is contained in:
ENDORFIT 2024-05-06 14:10:23 +04:00
parent e2b76217f9
commit 0fc655a6e3
5 changed files with 34 additions and 23 deletions

View File

@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using Serilog;
namespace ProjectMonorail
{
@ -28,11 +29,10 @@ namespace ProjectMonorail
private static void ConfigureServices(ServiceCollection services)
{
services.AddSingleton<FormMonorailCollection>()
.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
.AddLogging(option => option.AddSerilog(dispose: true));
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug().WriteTo.File("C:\\Ó÷åáà\\PIbd-11_Tarasov_V.D._Simple\\ProjectMonorail\\log.txt").CreateLogger();
}
}
}

View File

@ -9,6 +9,9 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
@ -23,9 +26,4 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -217,5 +217,17 @@ namespace ProjectMonorail.Scripts.Monorail.CollectionGenericObjects
_ => null,
};
}
public T? this[int index]
{
get
{
if (index >= 0 && index < Keys.Count && Keys[index] != null)
{
return (T)_storages[Keys[index]];
}
return null;
}
}
}
}

14
ProjectMonorail/log.txt Normal file
View File

@ -0,0 +1,14 @@
2024-05-06 13:58:46.635 +04:00 [INF] Форма загрузилась
2024-05-06 13:58:52.710 +04:00 [INF] Загрузка успешна завершена
2024-05-06 13:58:54.975 +04:00 [ERR] Ошибка Коллекция не выбрана
2024-05-06 14:05:27.673 +04:00 [INF] Форма загрузилась
2024-05-06 14:05:33.453 +04:00 [INF] Загрузка успешна завершена
2024-05-06 14:05:45.167 +04:00 [ERR] Ошибка Превышение лимита Count
2024-05-06 14:05:55.335 +04:00 [INF] Объект удален
2024-05-06 14:05:57.340 +04:00 [ERR] Ошибка Не найден объект по позиции 1
2024-05-06 14:05:59.747 +04:00 [ERR] Ошибка Не найден объект по позиции 1
2024-05-06 14:07:02.813 +04:00 [INF] Форма загрузилась
2024-05-06 14:07:56.306 +04:00 [INF] Загрузка успешна завершена
2024-05-06 14:08:05.188 +04:00 [ERR] Ошибка Превышение лимита Count
2024-05-06 14:08:10.722 +04:00 [INF] Объект удален
2024-05-06 14:08:14.155 +04:00 [ERR] Ошибка Не найден объект по позиции 1

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true" internalLogLevel="Info">
<targets>
<target xsi:type="File" name="tofile" fileName="MonorailLog-${shortdate}.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="tofile" />
</rules>
</nlog>
</configuration>