diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/AirPlaneWithRadar.csproj b/AirPlaneWithRadar/AirPlaneWithRadar/AirPlaneWithRadar.csproj index 13ee123..5e3bef9 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/AirPlaneWithRadar.csproj +++ b/AirPlaneWithRadar/AirPlaneWithRadar/AirPlaneWithRadar.csproj @@ -8,6 +8,23 @@ enable + + + + + + + Always + + + + + + + + + + True diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/FormMapWithSetPlains.cs b/AirPlaneWithRadar/AirPlaneWithRadar/FormMapWithSetPlains.cs index 5a14af4..b70561b 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/FormMapWithSetPlains.cs +++ b/AirPlaneWithRadar/AirPlaneWithRadar/FormMapWithSetPlains.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.Extensions.Logging; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -17,10 +18,11 @@ namespace AirPlaneWithRadar { "Простая карта", new SimpleMap()},{"Карта с большими коробками", new UserMap_BigBox()},{"Карта со стенами", new UserMap_Colums()} }; private readonly MapsCollection _mapsCollection; - - public FormMapWithSetPlains() + private readonly ILogger _logger; + public FormMapWithSetPlains(ILogger logger) { InitializeComponent(); + _logger = logger; _mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height); comboBoxSelectorMap.Items.Clear(); foreach (var elem in _mapsDict) @@ -62,6 +64,7 @@ namespace AirPlaneWithRadar } _mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]); ReloadMaps(); + _logger.LogInformation($"{textBoxNewMapName}"); } private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e) diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/Program.cs b/AirPlaneWithRadar/AirPlaneWithRadar/Program.cs index 8cb6b9c..d26028a 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/Program.cs +++ b/AirPlaneWithRadar/AirPlaneWithRadar/Program.cs @@ -1,3 +1,8 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; +using System; + namespace AirPlaneWithRadar { internal static class Program @@ -11,7 +16,23 @@ namespace AirPlaneWithRadar // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormMapWithSetPlains()); + var services = new ServiceCollection(); + ConfigureServices(services); + using (ServiceProvider serviceProvider = services.BuildServiceProvider()) + { + Application.Run(serviceProvider.GetRequiredService < FormMapWithSetPlains>()); + } } + + private static void ConfigureServices(ServiceCollection services) + { + services.AddSingleton() + .AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + } + } } \ No newline at end of file diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/nlog.config b/AirPlaneWithRadar/AirPlaneWithRadar/nlog.config new file mode 100644 index 0000000..5c71e85 --- /dev/null +++ b/AirPlaneWithRadar/AirPlaneWithRadar/nlog.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + \ No newline at end of file