55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using Serilog;
|
|
using Serilog.Events;
|
|
|
|
namespace Dolphin.ExamPictureCut;
|
|
|
|
public class Program
|
|
{
|
|
public async static Task<int> Main(string[] args)
|
|
{
|
|
Log.Logger = new LoggerConfiguration()
|
|
#if DEBUG
|
|
.MinimumLevel.Debug()
|
|
#else
|
|
.MinimumLevel.Information()
|
|
#endif
|
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
|
.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
|
|
.Enrich.FromLogContext()
|
|
.WriteTo.Async(c => c.File("Logs/.log", LogEventLevel.Information,
|
|
rollingInterval: RollingInterval.Day,
|
|
fileSizeLimitBytes: 1024 * 1024 * 10,
|
|
retainedFileCountLimit: 100,
|
|
rollOnFileSizeLimit: true)
|
|
)
|
|
.WriteTo.Async(c => c.Console())
|
|
.CreateLogger();
|
|
|
|
try
|
|
{
|
|
Log.Information("Starting Dolphin.ExamPictureCut.HttpApi.Host.");
|
|
Log.Information("Current Env:" + Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"));
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.Host.AddAppSettingsSecretsJson()
|
|
.UseAutofac()
|
|
.UseSerilog();
|
|
await builder.AddApplicationAsync<DolphinExamPictureCutHttpApiHostModule>();
|
|
var app = builder.Build();
|
|
await app.InitializeApplicationAsync();
|
|
await app.RunAsync();
|
|
return 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Fatal(ex, "Host terminated unexpectedly!");
|
|
return 1;
|
|
}
|
|
finally
|
|
{
|
|
Log.CloseAndFlush();
|
|
}
|
|
}
|
|
}
|
|
|
|
|