chore 抽象微服务基本类库
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user