Nlog Exception message: Target cannot be found: 'File'

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

Nlog Exception message: Target cannot be found: 'File'

Robert Burrows
We have the following NLog config below which works on dev and QA but with the same Nlog config and Nlog.dll in production when get the Nlog error  Exception type: ArgumentException     Exception message: Target cannot be found: 'File' (full event log warning below Nlog file).  Funny thing is when we change the name of Nlog.config to NlogOLD.config so the config file doesn't get picked up, our production asp.net web site works but we get no log .  Any help is greatly appreciated.  

<?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"
      autoReload="true">
    <targets>
      <target name="f1" xsi:type="File"
              fileName="E:\Program Files\CCLS\Logs\rvklog.txt"
              layout="${longdate} ${callsite} ${level} ${message}"/>
    </targets>
    <rules>
      <logger name="*" minlevel="Debug" writeTo="f1" />
    </rules>
</nlog>


vent code: 3005
Event message: An unhandled exception has occurred.
Event time: 2/1/2012 2:57:51 PM
Event time (UTC): 2/1/2012 8:57:51 PM
Event ID: 2551125c85c34a4eab74cbe43c6e684b
Event sequence: 2
Event occurrence: 1
Event detail code: 0
 
Application information:
    Application domain: /LM/W3SVC/1/Root/PaidLoans-5-129726034698785993
    Trust level: Full
    Application Virtual Path: /PaidLoans
    Application Path: e:\inetpub\wwwroot\PaidLoans\
    Machine name: CBASBCCWPRAPP01
 
Process information:
    Process ID: 560
    Process name: w3wp.exe
    Account name: NT AUTHORITY\NETWORK SERVICE
 
Exception information:
    Exception type: ArgumentException
    Exception message: Target cannot be found: 'File'
 
Request information:
    Request URL: http://localhost/paidloans/default.aspx 
    Request path: /paidloans/default.aspx
    User host address: 127.0.0.1
    User:  
    Is authenticated: False
    Authentication Type:  
    Thread account name: NT AUTHORITY\NETWORK SERVICE
 
Thread information:
    Thread ID: 5
    Thread account name: NT AUTHORITY\NETWORK SERVICE
    Is impersonating: False
    Stack trace:    at NLog.Config.Factory`2.CreateInstance(String name)
   at NLog.Config.XmlLoggingConfiguration.ParseTargetsElement(NLogXmlElement targetsElement)
   at NLog.Config.XmlLoggingConfiguration.ParseNLogElement(NLogXmlElement nlogElement, String baseDirectory)
   at NLog.Config.XmlLoggingConfiguration.ParseTopLevel(NLogXmlElement content, String baseDirectory)
   at NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader, String fileName, Boolean ignoreErrors)
 
 
Custom event details:

For more information, see Help and Support Center at
Reply | Threaded
Open this post in threaded view
|

Re: Nlog Exception message: Target cannot be found: 'File'

jfish222
Hello,

I'm new to NLog and have only been playing with it in a test console.

That said, if the configuration file is the same (simply moved to the prod server w/ an updated log path) can you confirm that the folder permissions for "E:\Program Files\CCLS\Logs\" have been set?

The account NETWORK SERVICE will require read/write access to the directory.
Please report back if you find a solution as I will soon be implementing a similar deployment. :)

Good luck!
Reply | Threaded
Open this post in threaded view
|

Re: Nlog Exception message: Target cannot be found: 'File'

Robert Burrows
jfish222 thanks for the suggestion.  Sorry for the delay in responding but we had to wait until another window to try your suggestion in our production environment.
We thought we had tried it before but wanted to confirm and unfortunately it did not work.  We are are now going to try within NLOG.config to try some redirection/extended debugging to try to find the exact error, but are still unsure what to do.
Reply | Threaded
Open this post in threaded view
|

Re: Nlog Exception message: Target cannot be found: 'File'

jfish222
I'm at a loss.  I tried your config in my test harness and it worked perfectly.
I am, however, running under my user account (Admin priv.)

This bit in your stack trace has my attention:

Exception information:
    Exception type: ArgumentException
    Exception message: Target cannot be found: 'File'

Is what you provided the entirety of your nlog config? Or is it just the sequence you wanted active?
My thinking is that there is a parsing error somewhere around the way.
Just grasping at straws  . . .

Reply | Threaded
Open this post in threaded view
|

Re: Nlog Exception message: Target cannot be found: 'File'

Robert Burrows
Again sorry for the delay in the response .  Yes that was the entire NLOG.config very strange since it works in dev and QA - believe some user permission issue - again thanks for your help