лаба 7 - В С Ё! (надеюсь)
This commit is contained in:
parent
4d7de8d19c
commit
793ecd010e
@ -1,20 +1,15 @@
|
|||||||
{
|
{
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [ "Serilog.Sinks.File" ],
|
"Using": [ "Serilog.Sinks.File" ],
|
||||||
"MinimumLevel": "Information",
|
"MinimumLevel": "Debug",
|
||||||
"WriteTo": [
|
"WriteTo": [
|
||||||
{
|
{
|
||||||
"Name": "File",
|
"Name": "File",
|
||||||
"Args": {
|
"Args": { "path": "log.txt" }
|
||||||
"path": "Logs/log_.log",
|
|
||||||
"rollingInterval": "Day",
|
|
||||||
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
|
|
||||||
"Properties": {
|
"Properties": {
|
||||||
"Application": "ProjectAirplaneWithRadar"
|
"Application": "Sample"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,29 +25,24 @@ namespace ProjectAirplaneWithRadar
|
|||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
//Application.Run(new FormAirplanesCollection());
|
string[] path = Directory.GetCurrentDirectory().Split('\\');
|
||||||
var services = new ServiceCollection();
|
string pathNeed = "";
|
||||||
ConfigureServices(services);
|
for (int i = 0; i < path.Length - 3; i++)
|
||||||
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
|
|
||||||
{
|
{
|
||||||
Application.Run(serviceProvider.GetRequiredService<FormAirplanesCollection>());
|
pathNeed += path[i] + "\\";
|
||||||
}
|
}
|
||||||
|
var configuration = new ConfigurationBuilder()
|
||||||
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
.AddJsonFile(path: $"{pathNeed}AppSettings.json", optional: false, reloadOnChange: true)
|
||||||
|
.Build();
|
||||||
|
Log.Logger = new LoggerConfiguration()
|
||||||
|
.ReadFrom.Configuration(configuration)
|
||||||
|
.CreateLogger();
|
||||||
|
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
Application.Run(new FormAirplanesCollection());
|
||||||
}
|
}
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddSingleton<FormAirplanesCollection>().AddLogging(option =>
|
|
||||||
{
|
|
||||||
string[] path = Directory.GetCurrentDirectory().Split('\\');
|
|
||||||
string pathNeed = "";
|
|
||||||
for (int i = 0; i < path.Length - 3; i++)
|
|
||||||
{
|
|
||||||
pathNeed += path[i] + "\\";
|
|
||||||
}
|
|
||||||
var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile(path: $"{pathNeed}appsettings.json", optional: false, reloadOnChange: true).Build();
|
|
||||||
var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
|
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
|
||||||
option.AddSerilog(logger);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user