答:解决方案已实现写入 Visual Studio 中的输出调试器窗口,因此 NLog 日志将在输出窗口中报告,并带有以下 Web.Config 标记。
虽然我发现在另一个窗口中打开 NotePad++ 是一个更好的解决方案。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<nlog xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="true"
xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<extensions>
<add assembly="WellsFargo.Diagnostics.Integration" />
</extensions>
<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<!--<variable name="myvar" value="myvalue" />-->
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets async="true">
<!--
add your targets here
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
-->
<target name="Mail" xsi:type="Mail" html="true" subject="Error Received" body="${longdate} ${uppercase:${level}} | ${callsite} | ${message} | ${newline}" to="robert.b.dannellyjr@wellsfargo.com" from="1TIX_NLog@wellsFargo.com" smtpServer="SMTP.AZURE.WELLSFARGO.NET" smtpPort="25"/>
<target xsi:type="File" name="logfile" fileName="..\..\..\logs\1TIX_NLog\AppNLog.log"
archiveEvery="Day"
archiveFileName="..\..\..\logs\App_NLog\AppNLog.{#}.log"
archiveNumbering="DateAndSequence"
archiveDateFormat="yyyy-MM-dd"
archiveAboveSize="104857600"
maxArchiveFiles="14" />
<target xsi:type="Debugger" name="debugger" layout="${longdate} ${uppercase:${level}}|${callsite}|${message}" />
<target xsi:type="NLogAppender" name="NLogAppender" layout="${longdate} ${uppercase:${level}}|${callsite}|${message}|${newline}" />
<!--<target xsi:type="Console" name="f" layout="${longdate} ${uppercase:${level}} | ${callsite} | ${message} | ${newline}" />-->
</targets>
<rules>
<!-- add your logging rules here -->
<logger name="*" levels="Error,Fatal" writeTo="Mail" />
<logger name="*" minlevel="Debug" writeTo="logfile" />
<!-- Writes NLog to debugger window in Visual Studio -->
<logger name="*" minlevel="Trace" writeTo="debugger" />
<!-- Writes NLogs to Splunk -->
<logger name="*" minlevel="Trace" writeTo="NLogAppender" />
<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" /> -->
</rules>
</nlog>
<connectionStrings>
<!-- Code Omitted ... -->