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.
48 lines
1.5 KiB
48 lines
1.5 KiB
namespace MyCompanyName.MyProjectName;
|
|
|
|
public class Program
|
|
{
|
|
public static async Task<int> Main(string[] args)
|
|
{
|
|
Log.Logger = new LoggerConfiguration()
|
|
.WriteTo.Async(c => c.File("Logs/logs.txt"))
|
|
.WriteTo.Async(c => c.Console())
|
|
.CreateBootstrapLogger();
|
|
|
|
try
|
|
{
|
|
Log.Information("MyCompanyName.MyProjectName.HttpApi.Host.");
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.Host
|
|
.AddAppSettingsSecretsJson()
|
|
.UseAutofac()
|
|
.UseSerilog((context, loggerConfiguration) =>
|
|
{
|
|
SerilogToEsExtensions.SetSerilogConfiguration(
|
|
loggerConfiguration,
|
|
context.Configuration);
|
|
});
|
|
// 设置MaxRequestBodySize
|
|
//builder.WebHost.ConfigureKestrel(options => options.Limits.MaxRequestBodySize = 52428800);
|
|
await builder.AddApplicationAsync<MyProjectNameHttpApiHostModule>();
|
|
var app = builder.Build();
|
|
await app.InitializeApplicationAsync();
|
|
await app.RunAsync();
|
|
return 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (ex is HostAbortedException)
|
|
{
|
|
throw;
|
|
}
|
|
|
|
Log.Fatal(ex, "Host terminated unexpectedly!");
|
|
return 1;
|
|
}
|
|
finally
|
|
{
|
|
await Log.CloseAndFlushAsync();
|
|
}
|
|
}
|
|
}
|