配置NLog电子邮件正文输出

| 我正在使用NLog v2 Beta记录创建并发送消息到第三方服务的VB.NET .DLL。登录到文件时,它可以正常工作,但是现在希望它也可以通过电子邮件将其自动捕获的错误发送给我。以下是我的NLog.config文件的相关位:
<?xml version=\"1.0\" encoding=\"utf-8\" ?>
<nlog xmlns=\"http://www.nlog-project.org/schemas/NLog.xsd\"
      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">

    <targets>
        <target name=\"papercut\" xsi:type=\"BufferingWrapper\" bufferSize=\"100\">
            <target xsi:type=\"PostFilteringWrapper\" defaultFilter=\"level >= LogLevel.Debug\">
                <target xsi:type=\"Mail\"
                    name=\"papercut\"
                    subject=\"Your app has errors\"
                    to=\"ToAddress@Domain.com\"
                    from=\"FromAddress@Domain.com\"
                    smtpServer=\"127.0.0.1\"
                    smtpPort=\"25\"
                    body={longdate}|{message} />
            </target>
        </target> 
    </targets>

    <rules>
        <logger name=\"*\" minlevel=\"Debug\" writeTo=\"papercut\"  />
    </rules>
</nlog>
默认情况下,它将仅在电子邮件正文中列出已记录的消息。我想在此之前记录日期/时间,因此一直在使用body =部分无济于事(它无法正确评估变量或导致NLog崩溃)。有人可以给我一个关于如何配置NLog的提示吗?     
已邀请:
似乎您在主体配置中缺少$,这可能是NLog崩溃的原因。
body = \"${longdate}| ${message}\"
有关邮件目标的更多信息 https://github.com/NLog/NLog/wiki/Mail-target 您还可以如下所示启用NLog错误本身的日志记录。
<nlog 
    xmlns=\"http://www.nlog-project.org/schemas/NLog.xsd\" 
    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"  
    autoReload=\"true\"
    throwExceptions=\"true\"
    internalLogFile=\"Nloglog.log\"
    internalLogLevel=\"Warn\"
    >


.....


</nlog>
    

要回复问题请先登录注册