如何将值从 C# 代码传递到 Nlog 电子邮件的正文

How to pass value from C# code to Nlog email's body

我想将我控件中的值传递到 nlog 的电子邮件正文中。

nlog.config

<target xsi:type="Mail"
            addNewLines = "true"
            name="NewRequestemail"
            to="${adminEmail}"
            subject="Please review a new [${systemName}] "
            html="true"
            body="${exception:format=tostring}"
            from="${systemEmail}"
            smtpServer="${smtpServer}" />


    <logger name="NewRequestemail" minlevel="Info" writeTo="NewRequestemail" />

HomeControl.cs

LogManager.GetLogger("NewRequestemail").Info("body", "Test Message");

我不确定应该立即将 "Test Massage" 传递到电子邮件正文中。到目前为止,我暂时收到空白电子邮件。请帮忙

使用${message},例如

body="${message} ${exception:format=tostring}"

记录器调用

LogManager.GetLogger("NewRequestemail").Info("my message");