NLog internal log not working with ASP.Net MVC

JuChom picture JuChom · Feb 24, 2012 · Viewed 10.1k times · Source

I have a problem with NLog for logging its internal logs with this configuration

<?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"
  internalLogFile="${basedir}/App_Data/NLog.log"
  internalLogLevel="Trace">

   <targets>
      <target name="debug"
              xsi:type="File" 
              fileName="${basedir}/App_Data/Site.log" />
   </targets>

   <rules>
      <logger name="*"
              writeTo="debug" />
   </rules>
</nlog>

The target "debug" is working well, but the internalLogFile is only working if I set it for exemple to "D:/NLog.log".

Any idea why this happening?

Answer

kolbasov picture kolbasov · Feb 24, 2012

You can't use layout renderers ${...} in the internalLogFile property. They are for a target's layout only:

<target layout="${...}" />

Try to use relative path like "..\App_Data\NLog.log"