OMG... i hope that's all, because i'm tired...

This commit is contained in:
ekallin 2023-11-21 00:27:27 +04:00
parent 8457a1d8dc
commit ccdc3c7ca0
10 changed files with 157 additions and 52 deletions

View File

@ -59,7 +59,7 @@
// maskedTextBoxNumber // maskedTextBoxNumber
// //
maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
maskedTextBoxNumber.Location = new Point(38, 532); maskedTextBoxNumber.Location = new Point(38, 342);
maskedTextBoxNumber.Mask = "0"; maskedTextBoxNumber.Mask = "0";
maskedTextBoxNumber.Name = "maskedTextBoxNumber"; maskedTextBoxNumber.Name = "maskedTextBoxNumber";
maskedTextBoxNumber.Size = new Size(156, 27); maskedTextBoxNumber.Size = new Size(156, 27);
@ -69,9 +69,9 @@
// //
ButtonRefreshCollection.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; ButtonRefreshCollection.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
ButtonRefreshCollection.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point); ButtonRefreshCollection.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point);
ButtonRefreshCollection.Location = new Point(45, 663); ButtonRefreshCollection.Location = new Point(38, 412);
ButtonRefreshCollection.Name = "ButtonRefreshCollection"; ButtonRefreshCollection.Name = "ButtonRefreshCollection";
ButtonRefreshCollection.Size = new Size(150, 41); ButtonRefreshCollection.Size = new Size(150, 29);
ButtonRefreshCollection.TabIndex = 2; ButtonRefreshCollection.TabIndex = 2;
ButtonRefreshCollection.Text = "Обновить все"; ButtonRefreshCollection.Text = "Обновить все";
ButtonRefreshCollection.UseVisualStyleBackColor = true; ButtonRefreshCollection.UseVisualStyleBackColor = true;
@ -80,9 +80,9 @@
// //
ButtonRemoveLocomotive.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; ButtonRemoveLocomotive.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
ButtonRemoveLocomotive.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point); ButtonRemoveLocomotive.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point);
ButtonRemoveLocomotive.Location = new Point(45, 590); ButtonRemoveLocomotive.Location = new Point(37, 375);
ButtonRemoveLocomotive.Name = "ButtonRemoveLocomotive"; ButtonRemoveLocomotive.Name = "ButtonRemoveLocomotive";
ButtonRemoveLocomotive.Size = new Size(150, 44); ButtonRemoveLocomotive.Size = new Size(150, 31);
ButtonRemoveLocomotive.TabIndex = 1; ButtonRemoveLocomotive.TabIndex = 1;
ButtonRemoveLocomotive.Text = "Удалить локо"; ButtonRemoveLocomotive.Text = "Удалить локо";
ButtonRemoveLocomotive.UseVisualStyleBackColor = true; ButtonRemoveLocomotive.UseVisualStyleBackColor = true;
@ -92,9 +92,9 @@
// //
ButtonAddLocomotive.Anchor = AnchorStyles.Top; ButtonAddLocomotive.Anchor = AnchorStyles.Top;
ButtonAddLocomotive.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point); ButtonAddLocomotive.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point);
ButtonAddLocomotive.Location = new Point(42, 461); ButtonAddLocomotive.Location = new Point(38, 306);
ButtonAddLocomotive.Name = "ButtonAddLocomotive"; ButtonAddLocomotive.Name = "ButtonAddLocomotive";
ButtonAddLocomotive.Size = new Size(150, 39); ButtonAddLocomotive.Size = new Size(150, 30);
ButtonAddLocomotive.TabIndex = 0; ButtonAddLocomotive.TabIndex = 0;
ButtonAddLocomotive.Text = "Добавить локо"; ButtonAddLocomotive.Text = "Добавить локо";
ButtonAddLocomotive.UseVisualStyleBackColor = true; ButtonAddLocomotive.UseVisualStyleBackColor = true;
@ -103,15 +103,15 @@
// pictureBoxCollections // pictureBoxCollections
// //
pictureBoxCollections.Anchor = AnchorStyles.Left; pictureBoxCollections.Anchor = AnchorStyles.Left;
pictureBoxCollections.Location = new Point(-1, 27); pictureBoxCollections.Location = new Point(-1, 31);
pictureBoxCollections.Name = "pictureBoxCollections"; pictureBoxCollections.Name = "pictureBoxCollections";
pictureBoxCollections.Size = new Size(1104, 692); pictureBoxCollections.Size = new Size(303, 409);
pictureBoxCollections.TabIndex = 1; pictureBoxCollections.TabIndex = 1;
pictureBoxCollections.TabStop = false; pictureBoxCollections.TabStop = false;
// //
// textBoxStorageName // textBoxStorageName
// //
textBoxStorageName.Location = new Point(31, 43); textBoxStorageName.Location = new Point(31, 28);
textBoxStorageName.Margin = new Padding(3, 4, 3, 4); textBoxStorageName.Margin = new Padding(3, 4, 3, 4);
textBoxStorageName.Name = "textBoxStorageName"; textBoxStorageName.Name = "textBoxStorageName";
textBoxStorageName.Size = new Size(149, 27); textBoxStorageName.Size = new Size(149, 27);
@ -119,6 +119,7 @@
// //
// groupBox1 // groupBox1
// //
groupBox1.Anchor = AnchorStyles.None;
groupBox1.Controls.Add(listBoxStorage); groupBox1.Controls.Add(listBoxStorage);
groupBox1.Controls.Add(ButtonAddObject); groupBox1.Controls.Add(ButtonAddObject);
groupBox1.Controls.Add(ButtonRemoveObject); groupBox1.Controls.Add(ButtonRemoveObject);
@ -127,7 +128,7 @@
groupBox1.Margin = new Padding(3, 4, 3, 4); groupBox1.Margin = new Padding(3, 4, 3, 4);
groupBox1.Name = "groupBox1"; groupBox1.Name = "groupBox1";
groupBox1.Padding = new Padding(3, 4, 3, 4); groupBox1.Padding = new Padding(3, 4, 3, 4);
groupBox1.Size = new Size(216, 395); groupBox1.Size = new Size(216, 270);
groupBox1.TabIndex = 5; groupBox1.TabIndex = 5;
groupBox1.TabStop = false; groupBox1.TabStop = false;
groupBox1.Text = "Наборы"; groupBox1.Text = "Наборы";
@ -136,7 +137,7 @@
// //
listBoxStorage.FormattingEnabled = true; listBoxStorage.FormattingEnabled = true;
listBoxStorage.ItemHeight = 20; listBoxStorage.ItemHeight = 20;
listBoxStorage.Location = new Point(31, 163); listBoxStorage.Location = new Point(31, 97);
listBoxStorage.Margin = new Padding(3, 4, 3, 4); listBoxStorage.Margin = new Padding(3, 4, 3, 4);
listBoxStorage.Name = "listBoxStorage"; listBoxStorage.Name = "listBoxStorage";
listBoxStorage.Size = new Size(149, 124); listBoxStorage.Size = new Size(149, 124);
@ -147,9 +148,9 @@
// //
ButtonAddObject.Anchor = AnchorStyles.Top; ButtonAddObject.Anchor = AnchorStyles.Top;
ButtonAddObject.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point); ButtonAddObject.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point);
ButtonAddObject.Location = new Point(31, 96); ButtonAddObject.Location = new Point(31, 62);
ButtonAddObject.Name = "ButtonAddObject"; ButtonAddObject.Name = "ButtonAddObject";
ButtonAddObject.Size = new Size(150, 39); ButtonAddObject.Size = new Size(149, 28);
ButtonAddObject.TabIndex = 7; ButtonAddObject.TabIndex = 7;
ButtonAddObject.Text = "Добавить набор"; ButtonAddObject.Text = "Добавить набор";
ButtonAddObject.UseVisualStyleBackColor = true; ButtonAddObject.UseVisualStyleBackColor = true;
@ -159,9 +160,9 @@
// //
ButtonRemoveObject.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; ButtonRemoveObject.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
ButtonRemoveObject.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point); ButtonRemoveObject.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point);
ButtonRemoveObject.Location = new Point(31, 325); ButtonRemoveObject.Location = new Point(31, 228);
ButtonRemoveObject.Name = "ButtonRemoveObject"; ButtonRemoveObject.Name = "ButtonRemoveObject";
ButtonRemoveObject.Size = new Size(150, 44); ButtonRemoveObject.Size = new Size(149, 31);
ButtonRemoveObject.TabIndex = 8; ButtonRemoveObject.TabIndex = 8;
ButtonRemoveObject.Text = "Удалить набор"; ButtonRemoveObject.Text = "Удалить набор";
ButtonRemoveObject.UseVisualStyleBackColor = true; ButtonRemoveObject.UseVisualStyleBackColor = true;
@ -175,11 +176,11 @@
Instruments.Controls.Add(maskedTextBoxNumber); Instruments.Controls.Add(maskedTextBoxNumber);
Instruments.Controls.Add(ButtonAddLocomotive); Instruments.Controls.Add(ButtonAddLocomotive);
Instruments.Controls.Add(ButtonRemoveLocomotive); Instruments.Controls.Add(ButtonRemoveLocomotive);
Instruments.Location = new Point(1102, 0); Instruments.Location = new Point(302, -1);
Instruments.Margin = new Padding(3, 4, 3, 4); Instruments.Margin = new Padding(3, 4, 3, 4);
Instruments.Name = "Instruments"; Instruments.Name = "Instruments";
Instruments.Padding = new Padding(3, 4, 3, 4); Instruments.Padding = new Padding(3, 4, 3, 4);
Instruments.Size = new Size(236, 719); Instruments.Size = new Size(236, 448);
Instruments.TabIndex = 6; Instruments.TabIndex = 6;
Instruments.TabStop = false; Instruments.TabStop = false;
Instruments.Text = "Инструменты"; Instruments.Text = "Инструменты";
@ -190,7 +191,7 @@
menuStrip1.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem }); menuStrip1.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
menuStrip1.Location = new Point(0, 0); menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1"; menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(1338, 28); menuStrip1.Size = new Size(538, 28);
menuStrip1.TabIndex = 7; menuStrip1.TabIndex = 7;
menuStrip1.Text = "menuStrip1"; menuStrip1.Text = "menuStrip1";
// //
@ -228,7 +229,7 @@
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1338, 724); ClientSize = new Size(538, 443);
Controls.Add(Instruments); Controls.Add(Instruments);
Controls.Add(pictureBoxCollections); Controls.Add(pictureBoxCollections);
Controls.Add(menuStrip1); Controls.Add(menuStrip1);

View File

@ -58,10 +58,13 @@ namespace ProjectElectricLocomotive
if (string.IsNullOrEmpty(textBoxStorageName.Text)) if (string.IsNullOrEmpty(textBoxStorageName.Text))
{ {
MessageBox.Show("Не всё заполнено", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Не всё заполнено", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogWarning("Неудачная попытка. Коллекция не добавлена, не все данные заполнены");
return; return;
} }
_storage.AddSet(textBoxStorageName.Text); _storage.AddSet(textBoxStorageName.Text);
ReloadObjects(); ReloadObjects();
_logger.LogInformation($"Добавлен набор: {textBoxStorageName.Text}");
} }
private void listBoxStorage_SelectedIndexChanged(object sender, EventArgs e) private void listBoxStorage_SelectedIndexChanged(object sender, EventArgs e)
@ -75,12 +78,15 @@ namespace ProjectElectricLocomotive
{ {
return; return;
} }
string name = listBoxStorage.SelectedItem.ToString() ?? string.Empty;
if (MessageBox.Show($"Удалить объект {listBoxStorage.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, if (MessageBox.Show($"Удалить объект {listBoxStorage.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes) MessageBoxIcon.Question) == DialogResult.Yes)
{ {
_storage.DelSet(listBoxStorage.SelectedItem.ToString() ?? string.Empty); _storage.DelSet(name);
ReloadObjects(); ReloadObjects();
_logger.LogInformation($"Набор '{name}' удален");
} }
_logger.LogWarning("Отмена удаления набора");
} }
private void ButtonAddLocomotive_Click(object sender, EventArgs e) private void ButtonAddLocomotive_Click(object sender, EventArgs e)
@ -102,17 +108,25 @@ namespace ProjectElectricLocomotive
{ {
return; return;
} }
try
{
if (obj + loco > -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollections.Image = obj.ShowLocomotives();
_logger.LogInformation($"Добавлен объект {obj}");
; }
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
catch (StorageOverflowException ex)
{
MessageBox.Show(ex.Message);
}
//проверяем, удалось ли нам загрузить объект //проверяем, удалось ли нам загрузить объект
if (obj + loco > -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollections.Image = obj.ShowLocomotives();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
} }
private void ButtonRemoveLocomotive_Click(object sender, EventArgs e) private void ButtonRemoveLocomotive_Click(object sender, EventArgs e)
@ -126,14 +140,17 @@ namespace ProjectElectricLocomotive
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{ {
_logger.LogWarning("Отмена удаления объекта");
return; return;
} }
int pos = Convert.ToInt32(maskedTextBoxNumber.Text); int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
try try
{ {
if (obj - pos != null) var removeObj = obj - pos;
if (removeObj != null)
{ {
MessageBox.Show("Объект удален"); MessageBox.Show("Объект удален");
_logger.LogInformation($"Удален объект с позиции{pos}");
pictureBoxCollections.Image = obj.ShowLocomotives(); pictureBoxCollections.Image = obj.ShowLocomotives();
} }
else else
@ -169,11 +186,12 @@ namespace ProjectElectricLocomotive
try try
{ {
_storage.SaveData(saveFileDialog.FileName); _storage.SaveData(saveFileDialog.FileName);
_logger.LogInformation($"Данные загружены в файл {saveFileDialog.FileName}");
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
_logger.LogWarning($"Не удалось сохранить информацию в файл: {ex.Message}");
} }
} }
} }
@ -190,11 +208,12 @@ namespace ProjectElectricLocomotive
try try
{ {
_storage.LoadData(openFileDialog.FileName); _storage.LoadData(openFileDialog.FileName);
_logger.LogInformation($"Данные загружены из файла {openFileDialog.FileName}");
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
_logger.LogWarning($"Не удалось загрузить информацию из файла: {ex.Message}");
} }
} }
} }

View File

@ -133,6 +133,6 @@
<value>615, 17</value> <value>615, 17</value>
</metadata> </metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>84</value> <value>25</value>
</metadata> </metadata>
</root> </root>

View File

@ -51,10 +51,7 @@ namespace ProjectElectricLocomotive.Generics
public static T? operator -(LocomotiveGenericCollection<T, U> collect, int pos) public static T? operator -(LocomotiveGenericCollection<T, U> collect, int pos)
{ {
T? obj = collect._collection[pos]; T? obj = collect._collection[pos];
if (obj != null) collect._collection.Remove(pos);
{
collect._collection.Remove(pos);
}
return obj; return obj;
} }

View File

@ -135,7 +135,7 @@ namespace ProjectElectricLocomotive.Generics
{ {
if (!File.Exists(filename)) if (!File.Exists(filename))
{ {
throw new Exception("Файл не найден"); throw new FileNotFoundException("Файл не найден");
} }
using (StreamReader fs = File.OpenText(filename)) using (StreamReader fs = File.OpenText(filename))
@ -145,13 +145,13 @@ namespace ProjectElectricLocomotive.Generics
if (str == null || str.Length == 0) if (str == null || str.Length == 0)
{ {
throw new Exception("Нет данных для загрузки"); throw new IOException("Нет данных для загрузки");
} }
if (!str.StartsWith("LocomotiveStorage")) if (!str.StartsWith("LocomotiveStorage"))
{ {
//если нет такой записи, то это не те данные //если нет такой записи, то это не те данные
throw new Exception("Неверный формат данных"); throw new FileFormatException("Неверный формат данных");
} }
_locomotivesStorage.Clear(); _locomotivesStorage.Clear();
@ -163,7 +163,7 @@ namespace ProjectElectricLocomotive.Generics
if (strs == null) if (strs == null)
{ {
throw new Exception("Нет данных для загрузки"); throw new FileNotFoundException("Нет данных для загрузки");
} }
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries); string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);

View File

@ -1,11 +1,14 @@
using ProjectElectricLocomotive; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog;
namespace ElectricLocomotive namespace ProjectElectricLocomotive
{ {
internal static class Program internal static class Program
{ {
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
[STAThread] [STAThread]
static void Main() static void Main()
@ -13,7 +16,30 @@ namespace ElectricLocomotive
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new FormLocomotiveCollections()); var services = new ServiceCollection();
ConfigureServices(services);
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
{
Application.Run(serviceProvider.GetRequiredService<FormLocomotiveCollections>());
}
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddSingleton<FormLocomotiveCollections>()
.AddLogging(option =>
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(path: "C:\\Users\\katri\\OneDrive\\Ðàáî÷èé ñòîë\\ÂÒÎÐÎÉ ÊÓÐÑ\\ÐÏÏ\\PIbd-21_Bakalskaya_E.D._ElectricLocomotive._BASE\\ProjectElectricLocomotive\\ProjectElectricLocomotive\\appSettings.json", optional: false, reloadOnChange: true)
.Build();
var logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.CreateLogger();
option.SetMinimumLevel(LogLevel.Information);
option.AddSerilog(logger);
});
} }
} }
} }

View File

@ -9,8 +9,26 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="nlog.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" 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" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" /> <PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,5 @@
using System; using ProjectElectricLocomotive.Exceptions;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -29,7 +30,14 @@ namespace ProjectElectricLocomotive.Generics
public int Insert(T loco, int position) public int Insert(T loco, int position)
{ {
if (position < 0 || position >= _maxCount) return -1; if(_places.Count >= _maxCount)
throw new StorageOverflowException(_maxCount);
if (position < 0 || position >= _maxCount)
{
return -1;
}
_places.Insert(position, loco); _places.Insert(position, loco);
return position; return position;
} }
@ -40,6 +48,8 @@ namespace ProjectElectricLocomotive.Generics
return null; return null;
T? tmp = _places[position]; T? tmp = _places[position];
if (tmp == null)
throw new LocoNotFoundException(position);
_places[position] = null; _places[position] = null;
return tmp; return tmp;
} }

View File

@ -0,0 +1,20 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Information",
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "log_.log",
"rollingInterval": "Day",
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"Properties": {
"Application": "Locomotives"
}
}
}

View File

@ -0,0 +1,14 @@
<?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="locolog-${shortdate}.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="tofile" />
</rules>
</nlog>
</configuration>