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();
|
||||
|
||||
|
||||
@@ -42,14 +42,14 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="logs\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="appsettings.Development.json">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Logs\BusinessFlow\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -24,11 +24,44 @@
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "logs/log-.log",
|
||||
"path": "Logs/log-.log",
|
||||
"rollingInterval": "Day"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "Logger",
|
||||
"Args": {
|
||||
"filter": "Equals(TAG, 'AuditFlow')",
|
||||
"writeTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/AuditFlow/log-.txt",
|
||||
"rollingInterval": "Day",
|
||||
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "Logger",
|
||||
"Args": {
|
||||
"filter": "Equals(TAG, 'BusinessFlow')",
|
||||
"writeTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/BusinessFlow/log-.txt",
|
||||
"rollingInterval": "Day",
|
||||
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"Enrich": [ "FromLogContext" ]
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Kestrel": {
|
||||
|
||||
Reference in New Issue
Block a user