You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.0 KiB
58 lines
2.0 KiB
using System;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Serilog;
|
|
|
|
namespace Win.Sfs.SettleAccount;
|
|
|
|
public class Program
|
|
{
|
|
public static int Main(string[] args)
|
|
{
|
|
var configuration = new ConfigurationBuilder()
|
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
|
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true, reloadOnChange: true);
|
|
|
|
Log.Logger = new LoggerConfiguration()
|
|
.WriteTo.Async(c => c.File("Logs/logs.txt"
|
|
, rollingInterval: RollingInterval.Day
|
|
, rollOnFileSizeLimit: true
|
|
, fileSizeLimitBytes: 30 * 1024 * 1024))
|
|
.WriteTo.Async(c => c.Console())
|
|
.CreateLogger();
|
|
|
|
try
|
|
{
|
|
Log.Information("Starting web host.");
|
|
CreateHostBuilder(args).Build().Run();
|
|
return 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Fatal(ex, "Host terminated unexpectedly!");
|
|
return 1;
|
|
}
|
|
finally
|
|
{
|
|
Log.CloseAndFlush();
|
|
}
|
|
}
|
|
|
|
internal static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
Host.CreateDefaultBuilder(args)
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
{
|
|
webBuilder.ConfigureKestrel((context, options) =>
|
|
{
|
|
//设置应用服务器Kestrel请求体最大为50MB
|
|
options.Limits.MaxRequestBodySize = long.MaxValue;
|
|
options.Limits.MaxRequestBufferSize = long.MaxValue;
|
|
options.Limits.MaxRequestLineSize = int.MaxValue;
|
|
options.Limits.KeepAliveTimeout = TimeSpan.MaxValue;
|
|
});
|
|
webBuilder.UseStartup<Startup>();
|
|
})
|
|
.UseAutofac()
|
|
.UseSerilog();
|
|
}
|
|
|