88 lines
3.1 KiB
C#
88 lines
3.1 KiB
C#
using Serilog;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Threading.Tasks;
|
||
using System.Windows.Forms;
|
||
using Serilog.Sinks.RollingFile;
|
||
using Microsoft.Extensions.Hosting;
|
||
using Microsoft.Extensions.DependencyInjection;
|
||
using solarApp.Service;
|
||
using Microsoft.Extensions.Logging;
|
||
|
||
namespace solarApp
|
||
{
|
||
static class Program
|
||
{
|
||
/// <summary>
|
||
/// The main entry point for the application.
|
||
/// log ref: https://www.thecodebuzz.com/file-logging-in-windows-form-application-using-serilog/
|
||
/// </summary>
|
||
[STAThread]
|
||
static void Main()
|
||
{
|
||
// Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||
// Application.EnableVisualStyles();
|
||
// Application.SetCompatibleTextRenderingDefault(false);
|
||
|
||
// ///Generate Host Builder and Register the Services for DI
|
||
// var builder = new HostBuilder()
|
||
// .ConfigureServices((hostContext, services) =>
|
||
// {
|
||
// services.AddScoped<fmArchive>();
|
||
// services.AddScoped<procArchiveHourly>();
|
||
// //services.AddScoped<IBusinessLayer, BusinessLayer>();
|
||
// //services.AddSingleton<IDataAccessLayer, CDataAccessLayer>();
|
||
|
||
|
||
////Add Serilog
|
||
//var serilogLogger = new LoggerConfiguration()
|
||
// .WriteTo.File("app_log.txt")
|
||
// .CreateLogger();
|
||
// services.AddLogging(x =>
|
||
// {
|
||
// x.SetMinimumLevel(LogLevel.Information);
|
||
// x.AddSerilog(logger: serilogLogger, dispose: true);
|
||
// });
|
||
|
||
// });
|
||
|
||
// var host = builder.Build();
|
||
|
||
// using (var serviceScope = host.Services.CreateScope())
|
||
// {
|
||
// var services = serviceScope.ServiceProvider;
|
||
// try
|
||
// {
|
||
// var form1 = services.GetRequiredService<fmArchive>();
|
||
// Application.Run(form1);
|
||
|
||
// Console.WriteLine("Success");
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// Console.WriteLine("Error Occured");
|
||
// }
|
||
// }
|
||
Log.Logger = new LoggerConfiguration()
|
||
.MinimumLevel.Verbose() // <20>]<5D>w<EFBFBD>̧C<CCA7><43><EFBFBD>ܼh<DCBC><68> <20>w<EFBFBD>]: Information
|
||
.WriteTo.File("Logs/solarApp/log-.log",
|
||
rollingInterval: RollingInterval.Day, // <20>C<EFBFBD>Ѥ@<40><><EFBFBD>ɮ<EFBFBD>
|
||
outputTemplate: "{Timestamp:HH:mm:ss} [{Level:u5}] {Message:lj}{NewLine}{Exception}"
|
||
) // <20><><EFBFBD>X<EFBFBD><58><EFBFBD>ɮ<EFBFBD> <20>ɦW<C9A6>d<EFBFBD><64>: log-20211005.log
|
||
.CreateLogger();
|
||
|
||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||
Application.EnableVisualStyles();
|
||
Application.SetCompatibleTextRenderingDefault(false);
|
||
//Application.Run(new fmExcel());
|
||
Application.Run(new fmArchive());
|
||
|
||
//Application.Run(new fmTest());
|
||
//Application.Run(new fmMain());
|
||
|
||
Log.CloseAndFlush();
|
||
}
|
||
}
|
||
}
|