Nlog IsDebugEnabled and all otheres are false

Viewed 582

I'm trying to setup Nlog for my solution. I have an Solutions with multiple Projects which make an add-in for Revit.

I followed all the instructions, setup my Nlog.config file, set up an Target and a Logger. But whenever I put a breakpoint on my Logger, all my IsEnabled messages are set to false.enter image description here

My Nlog.Config is like this :

<?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>

Then in my Main Class I Make the logger :

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

And Log the info I need, for example like this:

log.Info("OnStartup Initialized");

I tried Log4Net before and had exactly the same issues, and I'm really confused about it. Why isn't it logging, and what am I not seeing?

EDIT : When I add this to the Main, it does write a .txt file, however I still can't write my own logfile

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