Különböző logok, különböző file-ba
This commit is contained in:
@@ -11,13 +11,43 @@ using WorkFlowCheck.DL.Seed;
|
||||
using WorkFlowCheck.Common.RequestContext;
|
||||
using WorkFlowCheck.API.RequestContext;
|
||||
using WorkFlowCheck.API.Middleware;
|
||||
using Serilog.Filters;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
string baseLogPath = Path.Combine(Directory.GetCurrentDirectory(), "Logs");
|
||||
if (!Directory.Exists(baseLogPath))
|
||||
Directory.CreateDirectory(baseLogPath);
|
||||
|
||||
string auditLogPath = Path.Combine(Directory.GetCurrentDirectory(), "Logs", "AuditFlow");
|
||||
if (!Directory.Exists(auditLogPath))
|
||||
Directory.CreateDirectory(auditLogPath);
|
||||
|
||||
string businessLogPath = Path.Combine(Directory.GetCurrentDirectory(), "Logs", "BusinessFlow");
|
||||
if (!Directory.Exists(businessLogPath))
|
||||
Directory.CreateDirectory(businessLogPath);
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(builder.Configuration)
|
||||
.ReadFrom.Configuration(builder.Configuration) // Konfiguráció betöltése
|
||||
.WriteTo.Console()
|
||||
.WriteTo.File("logs/log-.log", rollingInterval: RollingInterval.Day)
|
||||
.WriteTo.Logger(lc => lc
|
||||
.Filter.ByIncludingOnly(Matching.WithProperty("TAG", "AuditFlow"))
|
||||
.WriteTo.File("Logs/AuditFlow/au-.log", rollingInterval: RollingInterval.Day)
|
||||
)
|
||||
.WriteTo.Logger(lc => lc
|
||||
.Filter.ByIncludingOnly(Matching.WithProperty("TAG", "BusinessFlow"))
|
||||
.WriteTo.File("Logs/BusinessFlow/bs-.log", rollingInterval: RollingInterval.Day)
|
||||
)
|
||||
.CreateLogger();
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Log.ForContext("TAG", "BusinessFlow").Information("API indítása...");
|
||||
|
||||
builder.Services.AddAutoMapper(typeof(MapperProfile));
|
||||
builder.Services.AddMemoryCache();
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
@@ -141,5 +171,7 @@ app.UseMiddleware<JwtMiddleware>();
|
||||
app.MapControllers();
|
||||
app.UseAuthorization();
|
||||
app.UseCors();
|
||||
|
||||
Log.ForContext("TAG", "BusinessFlow").Information("API fut.");
|
||||
app.Run();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user