This commit is contained in:
ityurner02@mail.ru 2022-11-21 09:27:37 +04:00
parent f809f7eb78
commit cf5bb6bee1
5 changed files with 27 additions and 25 deletions

View File

@ -8,22 +8,16 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<None Remove="nlog.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.1.0" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using Serilog;
namespace AntiAircraftGun
{
@ -27,8 +29,15 @@ namespace AntiAircraftGun
services.AddSingleton<FormMapWithSetAntiAircraftGuns>()
.AddLogging(option =>
{
var configuration = new ConfigurationBuilder()
.AddJsonFile("C:\\Óíèâåðñèòåò\\2 êóðñ\\ÐÏÏ\\AntiAircraftGun\\AntiAircraftGun\\AntiAircraftGun\\seriLog.json")
.Build();
var Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.CreateLogger();
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
option.AddSerilog(Logger);
});
}
}

View File

@ -62,7 +62,7 @@ namespace AntiAircraftGun
/// <returns></returns>
public T Remove(int position)
{
if (position < 0 || position >= _places.Count) throw new AntiAircraftGunNotFoundException(position); ;
if (position >= _places.Count) throw new AntiAircraftGunNotFoundException(position);
if (_places[position] == null) throw new AntiAircraftGunNotFoundException(position);
T removed = _places[position];
_places.RemoveAt(position);

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="carlog-${shortdate}.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="tofile" />
</rules>
</nlog>
</configuration>

View File

@ -0,0 +1,12 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "File",
"Args": { "path": "C:\\Университет\\2 курс\\РПП\\AntiAircraftGun\\AntiAircraftGun\\AntiAircraftGun\\bin\\Debug\\net6.0-windows\\Log.txt" }
}
]
}
}