C# Nlog未记录stacktrace

C# Nlog未记录stacktrace,c#,logging,stack-trace,nlog,C#,Logging,Stack Trace,Nlog,我的NLog配置如下 <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <targets> <target name="file" xsi:type="File" fileName="${basedir}/log${shortdate}.txt" archiv

我的NLog配置如下

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <targets>
      <target name="file" xsi:type="File" fileName="${basedir}/log${shortdate}.txt" archiveAboveSize="500000" archiveEvery="Day" archiveNumbering="Rolling" maxArchiveFiles="10" layout="${date:format=s}|${level}|${callsite}|${identity}|${message}|${exception:format=stacktrace}"/>
      <!--<target name="console" xsi:type="Console" />-->
    </targets>
    <rules>
      <logger name="*" minlevel="Debug" writeTo="file" />
      <!--<logger name="*" minlevel="Debug" writeTo="console" />-->
    </rules>
  </nlog>
public void Error(string message, Exception ex)
    {
        logger.Error(message, ex);
    }
我在日志中得到消息,但没有堆栈跟踪


提前感谢

在布局中尝试以下方法:

${exception:format=ToString}

您是否尝试过使用
logger.ErrorException(message,ex)而不是记录器。错误?

TrustyCoder-您可以在使用NLog输出异常的位置发布代码吗?你在NLog中也得到了输出吗?@TrustyCoder:这很令人困惑。我也在使用NLOG2.0,这对我很有用。您确定调用了正确的方法重载(即,将异常作为参数的方法重载)?@SerG什么是过时的<代码>错误异常
?这有记录吗?@Snixtor是的。它就记录在代码中,属性为
[过时(“改用错误(字符串,异常)方法”)]
@Serg深入到源代码中,并没有那么简单。下载v3.2.0版本的源代码和
记录器。ErrorException
方法未标记为过时。您引用的属性在源代码中的
ILogger
界面中可见,但该界面不是3.2.0版本的一部分!更进一步,即使主控中的
ILogger.ErrorException
标记为过时,
Logger.ErrorException
则不是。这绝对不是明确的。