Target File not found

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Target File not found

troyd
I had previously gotten NLog working in one of my projects, but now I seem to be having problems.  I have a program that runs in SQL's CLR that uses NLog for it's logging.  I've created a sqlservr.exe.nlog file that has the following:

<?xml version="1.0" ?>
<nlog autoReload="true"> 
  <targets>
    <target name="file" type="File" fileName="${basedir}/log.txt" />
  </targets>
  <rules>
    <logger name="*" minLevel="Trace" writeTo="file" />
  </rules>
</nlog>

When I run my sql clr stored proc I get the following:

Msg 6522, Level 16, State 1, Procedure NLogWrite, Line 0
A .NET Framework error occurred during execution of user-defined routine or aggregate "NLogWrite":
NLog.Config.NLogConfigurationException: Exception occured when loading configuration from 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe.nlog' ---> System.ArgumentException: Target File not found.
System.ArgumentException:
   at NLog.TargetFactory.CreateTarget(String name)
   at NLog.Config.XmlLoggingConfiguration.ConfigureTargetsFromElement(XmlElement element)
   at NLog.Config.XmlLoggingConfiguration.ConfigureFromXmlElement(XmlElement configElement, String baseDirectory)
   at NLog.Config.XmlLoggingConfiguration.ConfigureFromFile(String fileName)
   at NLog.Config.XmlLoggingConfiguration..ctor(String fileName, Boolean ignoreErrors)
NLog.Config.NLogConfigurationException:
   at NLog.Config.XmlLoggingConfiguration..ctor(String fileName, Boolean ignoreErrors)
   at NLog.LogFactory.get_Configuration()
   at NLog.LogFactory.GetLogger(LoggerCacheKey cacheKey)
   at NLog.LogManager.GetCurrentClassLogger()
   at NlogWrite.bmi_CLR_StoredProcs.NlogWrite(SqlString msgToWrite)
.
I have registered the latest version of NLog in SQL CLR


Reply | Threaded
Open this post in threaded view
|

Re: Target File not found

rahul
I have the same problem.  I can successfully get this to work on my development machine and a couple production machines, but one production machine is complaining that it can't find the targets.  The deployment process for all these machines is the same (web service publish in VS).  NLog.dll is in the bin folder, and I am not using any ASP .NET targets which would require the Extensions dll (just using simple file targets).
Reply | Threaded
Open this post in threaded view
|

Re: Target File not found

rahul
This started working after I applied the 3.5 SP1 update (which includes updates to .NET 2.0, notably updates to XML handling)

KB951847
Reply | Threaded
Open this post in threaded view
|

Re: Target File not found

Milan
Hi all, I had this issue, and it was related to a nonexistent logger-rule. I.e.

    <rules>
        <logger name="*" minlevel="Debug" writeTo="rtb_log" />
        <logger name="*" minlevel="Debug" writeTo="file" />                      <-- DOES NOT EXIST
    </rules>


After I removed this rule, everything worked fine.
Regards,
Milan