NLog target cannot be found

761 views
Skip to first unread message

Lloyd Kinsella

unread,
Feb 11, 2014, 7:15:57 AM2/11/14
to nlog-...@googlegroups.com
I'm having issues today with an NLog configuration that previously worked. My `NLog.config` looks something 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">
   
     
<extensions>
       
<add assembly="StudyGroup.Logging.NLog" />
     
</extensions>
   
     
<targets>
       
<target xsi:type="StudyGroup" name="StudyGroup" enabled="false" product="SalesForce (Uploader)" application="Application" />
   
       
<target xsi:type="ColoredConsole" name="Console" layout="${message} ${exception:format=ToString}" />
   
     
</targets>
   
     
<rules>
       
<logger name="*" writeTo="Console,StudyGroup" minlevel="Debug" />
     
</rules>
   
</nlog>


However all of a sudden I'm getting this exception thrown:

    Unhandled Exception: System.TypeInitializationException: The type initializer fo
    r 'SalesForce.Uploader.UploaderService' threw an exception. ---> NLog.NLogConfig
    urationException: Exception occurred when loading configuration from D:\Services
    \SalesForceUploader\NLog.config ---> System.ArgumentException: Target cannot be
    found: 'StudyGroup'
       at NLog.Config.Factory`2.CreateInstance(String name)
       at NLog.Config.XmlLoggingConfiguration.ParseTargetsElement(NLogXmlElement tar
    getsElement)
       at NLog.Config.XmlLoggingConfiguration.ParseNLogElement(NLogXmlElement nlogEl
    ement, String baseDirectory)
       at NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader, String fi
    leName, Boolean ignoreErrors)
       --- End of inner exception stack trace ---
       at NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader, String fi
    leName, Boolean ignoreErrors)
       at NLog.Config.XmlLoggingConfiguration..ctor(String fileName)
       at NLog.LogFactory.get_Configuration()
       at NLog.LogFactory.GetLogger(LoggerCacheKey cacheKey)
       at NLog.LogManager.GetCurrentClassLogger()
       at SalesForce.Uploader.UploaderService..cctor()
       --- End of inner exception stack trace ---
       at SalesForce.Uploader.UploaderService.Main(String[] args)

And I can't figure why. This used to work and still does in other projects except this one. I know for sure StudyGroup.Logging.NLog contains my target class, properly attributes etc.

Anyone any thoughts on what's going on?

Lloyd Kinsella

unread,
Feb 11, 2014, 10:18:01 AM2/11/14
to nlog-...@googlegroups.com
Resolved it. NLog version mismatch it seems between my assemblies and the application.

Kim Christensen

unread,
Feb 11, 2014, 4:56:04 PM2/11/14
to nlog-...@googlegroups.com

Glad you figured this out

Reply all
Reply to author
Forward
0 new messages