chore 抽象微服务基本类库

This commit is contained in:
2025-10-03 18:04:57 +08:00
parent 886cec11fb
commit c667df1ce3
34 changed files with 1335 additions and 323 deletions

View File

@ -0,0 +1,24 @@
using Serilog;
using Serilog.Events;
namespace KonSoft.Shared.Hosting.AspNetCore;
public static class SerilogConfigurationHelper
{
public static void Configure(string applicationName)
{
Log.Logger = new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Debug()
#else
.MinimumLevel.Information()
#endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
.Enrich.WithProperty("Application", $"{applicationName}")
.WriteTo.Async(c => c.File("Logs/logs.txt"))
.WriteTo.Async(c => c.Console())
.CreateLogger();
}
}