【发布时间】:2020-12-17 04:49:42
【问题描述】:
以这个简单的 NLog 示例配置为例:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="logfile" xsi:type="File" fileName="file.txt" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile" />
</rules>
</nlog>
如何将其设置为仅在调试时记录,而不是在生产中运行时记录?
编辑:
让事情变得更具挑战性:我的 NLog 配置文件是集中式的,在所有应用程序/服务/站点上共享。所以我想避免改变每一个项目,只修改配置文件。
【问题讨论】:
-
您的应用程序是什么类型的?对于网络应用程序,最好的方法是使用web.config transformations
-
该解决方案应该适用于 Web 和桌面应用程序。
标签: nlog