fix(log): 修复 DbUpdateException 日志丢失 InnerException 的问题
- NLog.config: exception layout 从 format=Message 改为 format=toString 原配置只渲染外层异常 Message,不递归 InnerException。DbUpdateException 外层 Message 永远是 "See the inner exception for details.",真正的 SQL 错误(主键冲突/字段超长/外键约束)全在 InnerException 里被吞掉。 改为 toString 后输出完整异常链(含 InnerException + 堆栈),全局生效。 - SwapTrade2Controller.tradeEditJson catch 块对齐其他 Controller: e.Message → e.GetBaseException().Message,并补上 e.ToJson() 数据参数, 让前端也能拿到最内层错误信息。 验证:dotnet build 0 错误
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Autofac.Core;
|
||||
using Autofac.Core;
|
||||
using BaseOUDAL;
|
||||
using CsvHelper;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
@@ -378,7 +378,7 @@ namespace YLErp.Web.Controllers
|
||||
catch (Exception e)
|
||||
{
|
||||
LogFactory.GetLogger("交易保存").Error(e);
|
||||
return JsonError("保存失败:" + e.Message);
|
||||
return JsonError("保存失败:" + e.GetBaseException().Message, e.ToJson());
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<targets>
|
||||
<!---Debug日志-->
|
||||
<target name="debug" xsi:type="Console" layout="${longdate}|${logger}|${uppercase:${level}}[${threadid}]|${message};${exception:format=Message}" />
|
||||
<target name="debug" xsi:type="Console" layout="${longdate}|${logger}|${uppercase:${level}}[${threadid}]|${message};${exception:format=toString}" />
|
||||
|
||||
<target xsi:type="Console" name="lifetimeConsole" layout="${MicrosoftConsoleLayout}" />
|
||||
</targets>
|
||||
|
||||
Reference in New Issue
Block a user