mirror of
https://github.com/239573049/FastGateway.git
synced 2026-10-17 05:20:30 +08:00
解决日志写入异常
This commit is contained in:
@@ -30,7 +30,15 @@ public class RequestLogService
|
||||
{
|
||||
while (_channel.Reader.TryRead(out var requestLog))
|
||||
{
|
||||
await _freeSql.Insert(requestLog).ExecuteAffrowsAsync();
|
||||
try
|
||||
{
|
||||
requestLog.Id = Guid.NewGuid().ToString("N");
|
||||
await _freeSql.Insert(requestLog).ExecuteAffrowsAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,10 +47,10 @@ public class RequestLogService
|
||||
{
|
||||
// 获取系统配置
|
||||
var day = await _settingService.GetAsync<int>(Constant.Setting.LogRetentionTime);
|
||||
|
||||
|
||||
// 计算时间差
|
||||
var startTime = DateTime.Now.AddDays(-day);
|
||||
|
||||
|
||||
// 删除数据
|
||||
return await _freeSql.Delete<RequestLog>().Where(x => x.CreatedTime <= startTime).ExecuteAffrowsAsync();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"Urls":"http://*:8080;https://*:8081",
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Data Source=/data/Gateway.db"
|
||||
|
||||
Reference in New Issue
Block a user