【发布时间】:2019-12-27 02:10:25
【问题描述】:
我正在使用 ASP.NET Core 记录器和 NLog。当我记录带有异常的错误/严重时,会记录消息,但不会记录异常。
try
{
// my code throws an exception
}
catch (Exception ex)
{
_logger.LogError($"There was an error", ex);
return null;
}
我的 NLog 配置如下所示:
<target xsi:type="File" name="ApiLogger" fileName="Logs\api-${shortdate}.log"
layout="${longdate} - ${uppercase:${level}} - ${threadid} - ${logger} - ${message} ${exception:innerFormat=Message,StackTrace}" />
文件中记录的是There was an error,没有实际的异常和堆栈跟踪。
【问题讨论】:
标签: c# asp.net-core nlog