7 лабу сдал
This commit is contained in:
parent
e367b85072
commit
a4a89b5f21
@ -17,22 +17,25 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="nlog.config" />
|
||||
<None Remove="serilog.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="nlog.config">
|
||||
<EmbeddedResource Include="serilog.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||
<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.Extensions.Logging" Version="3.1.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -12,9 +12,10 @@ namespace AirBomber
|
||||
{
|
||||
public partial class FormAirBomberConfig : Form
|
||||
{
|
||||
DrawningBomber _airBomber = null;
|
||||
static DrawningBomber _airBomber = null;
|
||||
|
||||
private Action<DrawningBomber> EventAddAirBomber;
|
||||
|
||||
public FormAirBomberConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -51,6 +52,7 @@ namespace AirBomber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
|
@ -45,7 +45,7 @@ namespace AirBomber
|
||||
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
|
||||
{
|
||||
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
|
||||
}
|
||||
}
|
||||
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >=
|
||||
listBoxMaps.Items.Count))
|
||||
{
|
||||
|
@ -56,8 +56,7 @@ namespace AirBomber
|
||||
sw.Write($"MapsCollection{Environment.NewLine}");
|
||||
foreach (var storage in _mapStorages)
|
||||
{
|
||||
sw.Write($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict,
|
||||
separatorData)}{Environment.NewLine}");
|
||||
sw.Write($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}{Environment.NewLine}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
using Serilog;
|
||||
using System.ServiceProcess;
|
||||
|
||||
@ -27,13 +27,18 @@ namespace AirBomber
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
var serilogLogger = new LoggerConfiguration().WriteTo.File("seriallog.txt").CreateLogger();
|
||||
|
||||
services.AddSingleton<FormMapWithSetAirBomber>()
|
||||
.AddLogging(option =>
|
||||
{
|
||||
var config = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("serilog.json")
|
||||
.Build();
|
||||
|
||||
Log.Logger = new LoggerConfiguration().ReadFrom.Configuration(config).CreateLogger();
|
||||
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddSerilog(logger: serilogLogger, dispose: true);
|
||||
option.AddSerilog();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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="airBomberlog-${shortdate}.log" />
|
||||
</targets>
|
||||
<rules>
|
||||
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
||||
</rules>
|
||||
</nlog>
|
||||
</configuration>
|
17
AirBomber/AirBomber/serilog.json
Normal file
17
AirBomber/AirBomber/serilog.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"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}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user