首页 > 解决方案 > 使用 Nlog 创建日志文件。创建引导程序包并使用它安装在我的机器上后,不会生成日志文件

问题描述

我的 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"
      throwExceptions="true">

  <targets>
    <target name="logfile" xsi:type="File" fileName="${basedir}/log.txt" />
    <target name="logconsole" xsi:type="Console" />
  </targets>

  <rules>
    <logger name="*" minlevel="Info" writeTo="logconsole" />
    <logger name="*" minlevel="Debug" writeTo="logfile" />
  </rules>
</nlog>

注意 1:我已经测试了这个文件的变体,但没有结果。

注意 2:通过 Visual Studio 日志记录运行应用程序可以正常工作。

我的设置是

编译动作:内容

复制到目录:始终复制

标签: c#visual-studionlog

解决方案


推荐阅读