Nlog IsDebugEnabled,其他均为false

问题描述

我正在尝试为我的解决方案设置Nlog。我有一个包含多个项目的解决方案,这些解决方案为Revit添加了一个插件。

我按照所有说明进行操作,设置了Nlog.config文件,设置了目标和记录器。 但是,每当我在Logger上放置一个断点时,我所有的IsEnabled消息都将设置为false。

enter image description here

我的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"
      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
      autoReload="true"
      throwExceptions="false"
      internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">

  <variable name="myvar" value="myvalue"/>

  <targets>
    <target xsi:type="File" name="LoggerForBaseReference" fileName="C:\temp\${shortdate}.log"
            layout="${longdate} ${uppercase:${level}} ${message}" />
  </targets>

  <rules>
    <logger name="AppLogRule" minlevel="Debug" writeTo="LoggerForBaseReference" />
  </rules>
</nlog>

然后在我的主课堂上,我创建记录器:

private static Logger log = LogManager.GetLogger("AppLogRule");

并记录我需要的信息,例如:

log.Info("OnStartup Initialized");

我以前尝试过Log4Net,但遇到了完全相同的问题,对此我感到非常困惑。 为什么不记录日志,我看不到什么?

编辑: 当我将其添加到Main中时,它确实会写入.txt文件,但是我仍然无法编写自己的日志文件

NLog.Common.InternalLogger.LogLevel = LogLevel.Debug;
NLog.Common.InternalLogger.LogToConsole = true;
NLog.Common.InternalLogger.LogFile = "C:\\Temp\\NLog.Internal.txt";

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...