Files
Yi.Admin/Yi.Abp.Net8/src/Yi.Abp.Web/Program.cs

47 lines
1.4 KiB
C#
Raw Normal View History

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-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);
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();
}