2023-12-12 14:33:32 +08:00
|
|
|
|
using Serilog;
|
2023-12-12 17:16:28 +08:00
|
|
|
|
using Serilog.Events;
|
2023-12-11 09:55:12 +08:00
|
|
|
|
using Yi.Abp.Web;
|
|
|
|
|
|
|
2024-01-05 09:25:02 +08:00
|
|
|
|
//创建日志,可使用{SourceContext}记录
|
2023-12-12 14:33:32 +08:00
|
|
|
|
Log.Logger = new LoggerConfiguration()
|
2023-12-12 17:16:28 +08:00
|
|
|
|
.MinimumLevel.Debug()
|
|
|
|
|
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
2024-01-10 15:03:26 +08:00
|
|
|
|
.MinimumLevel.Override("Microsoft.AspNetCore.Hosting.Diagnostics", LogEventLevel.Error)
|
2023-12-12 17:16:28 +08:00
|
|
|
|
.MinimumLevel.Override("Quartz", LogEventLevel.Warning)
|
|
|
|
|
|
.Enrich.FromLogContext()
|
2024-01-10 15:03:26 +08:00
|
|
|
|
.WriteTo.Async(c => c.File("logs/all/log-.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Debug))
|
|
|
|
|
|
.WriteTo.Async(c => c.File("logs/error/errorlog-.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Error))
|
2024-01-22 18:30:01 +08:00
|
|
|
|
.WriteTo.Async(c => c.Console())
|
2023-12-12 14:33:32 +08:00
|
|
|
|
.CreateLogger();
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2024-03-06 18:35:34 +08:00
|
|
|
|
Log.Information("""
|
|
|
|
|
|
|
2024-03-06 18:46:33 +08:00
|
|
|
|
__ ___ ______ _
|
|
|
|
|
|
\ \ / (_) | ____| | |
|
|
|
|
|
|
\ \_/ / _ | |__ _ __ __ _ _ __ ___ _____ _____ _ __| | __
|
|
|
|
|
|
\ / | | | __| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
|
|
|
|
|
|
| | | | | | | | | (_| | | | | | | __/\ V V / (_) | | | <
|
|
|
|
|
|
|_| |_| |_| |_| \__,_|_| |_| |_|\___| \_/\_/ \___/|_| |_|\_\
|
|
|
|
|
|
|
|
|
|
|
|
""");
|
2024-01-05 09:25:02 +08:00
|
|
|
|
Log.Information("Yi框架-Abp.vNext,启动!");
|
2023-12-12 14:33:32 +08:00
|
|
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
2024-04-28 14:47:20 +08:00
|
|
|
|
Log.Information($"当前主机启动环境-【{builder.Environment.EnvironmentName}】");
|
|
|
|
|
|
Log.Information($"当前主机启动地址-【{builder.Configuration["App:SelfUrl"]}】");
|
2023-12-12 14:33:32 +08:00
|
|
|
|
builder.WebHost.UseUrls(builder.Configuration["App:SelfUrl"]);
|
|
|
|
|
|
builder.Host.UseAutofac();
|
|
|
|
|
|
builder.Host.UseSerilog();
|
|
|
|
|
|
await builder.Services.AddApplicationAsync<YiAbpWebModule>();
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
await app.InitializeApplicationAsync();
|
|
|
|
|
|
await app.RunAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
2024-01-05 09:25:02 +08:00
|
|
|
|
Log.Fatal(ex, "Yi框架-Abp.vNext,爆炸!");
|
2023-12-12 14:33:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
finally
|
|
|
|
|
|
{
|
|
|
|
|
|
Log.CloseAndFlush();
|
|
|
|
|
|
}
|