|
|
|
|
using System;
|
|
|
|
|
using Autofac.Extensions.DependencyInjection;
|
|
|
|
|
using CoreCms.Net.Loging;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using NLog.Web;
|
|
|
|
|
using LogLevel = NLog.LogLevel;
|
|
|
|
|
|
|
|
|
|
namespace CoreCms.Net.Web.WebApi
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="args"></param>
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
var host = CreateHostBuilder(args).Build();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//ȷ<><C8B7>NLog.config<69><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>appsettings.json<6F><6E>ͬ<EFBFBD><CDAC>
|
|
|
|
|
NLogUtil.EnsureNlogConfig("NLog.config");
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
NLogUtil.WriteAll(LogLevel.Trace, LogType.Web, "<22>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD>", "<22>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>");
|
|
|
|
|
|
|
|
|
|
host.Run();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//ʹ<><CAB9>nlogд<67><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ݿ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>/<2F><><EFBFBD>ӳɹ<D3B3><C9B9><EFBFBD>
|
|
|
|
|
NLogUtil.WriteFileLog(LogLevel.Error, LogType.ApiRequest, "<22>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD>", "<22><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣", ex);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="args"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args)
|
|
|
|
|
{
|
|
|
|
|
return Host.CreateDefaultBuilder(args)
|
|
|
|
|
.UseServiceProviderFactory(new AutofacServiceProviderFactory()) //<--NOTE THIS
|
|
|
|
|
.ConfigureLogging(logging =>
|
|
|
|
|
{
|
|
|
|
|
logging.ClearProviders(); //<2F>Ƴ<EFBFBD><C6B3>Ѿ<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
|
|
|
|
|
})
|
|
|
|
|
.UseNLog() //NLog: Setup NLog for Dependency injection
|
|
|
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
|
|
|
{
|
|
|
|
|
webBuilder
|
|
|
|
|
.ConfigureKestrel(serverOptions =>
|
|
|
|
|
{
|
|
|
|
|
serverOptions.AllowSynchronousIO = true; //<2F><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC> IO
|
|
|
|
|
})
|
|
|
|
|
.UseStartup<Startup>();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|