Parameter xsi not supported on FileTarget

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

Parameter xsi not supported on FileTarget

Geofrey
Hi,

I declared Nlog as the followings in my web.config:

<configuration>
  <configSections>
    <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
  </configSections>
  <nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <extensions>
      <add assembly="NLog.Extended" />
    </extensions>
    <targets>
      <target name="HttpModuleFile" xsi:type="File" layout="${date:format=HH\:mm\:ss} - ${level} - ${callsite:includeSourcePath=false} - ${message}" fileName="C:\logs\GST.Extranet\HttpMolues.log" archiveFileName="C:\logs\GST.Extranet\archives\HttpModules{#####}.log" archiveEvery="Day" archiveNumbering="Rolling" keepFileOpen="false" encoding="iso-8859-2" />
      <target name="MsgInspectorFile" xsi:type="File" layout="${date:format=HH\:mm\:ss} - ${level} - ${callsite:includeSourcePath=false} - ${message}" fileName="C:\logs\GST.Extranet.Services\BeforeSendRequest.log" archiveFileName="C:\logs\GST.Extranet.Services\archives\BeforeSendRequest{#####}.log" archiveEvery="Day" archiveNumbering="Rolling" keepFileOpen="false" encoding="iso-8859-2" />
      <target name="GlobalLogFile" xsi:type="File" layout="${date:format=HH\:mm\:ss} - ${level} - ${callsite:includeSourcePath=false} - ${message}" fileName="C:\logs\GST.Extranet\Global.log" archiveFileName="C:\logs\GST.Extranet\archives\Global{#####}.log" archiveEvery="Day" archiveNumbering="Rolling" keepFileOpen="false" encoding="iso-8859-2" />
    </targets>
    <rules>
      <logger name="GST.Extranet.Application.Global" minlevel="Trace" writeTo="GlobalLogFile" />
      <logger name="GST.Extranet.Security.HttpModule.*" minlevel="Trace" writeTo="HttpModuleFile" />
      <logger name="GST.Extranet.Security.ServiceBehavior.*" minlevel="Trace" writeTo="MsgInspectorFile" />
    </rules>
  </nlog>
 ...
</configuration>

When deploying our projet in local, there is no problem.
When deploying in our pre-prod environment (on a machine being in a DMZ) I got this error:


Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: An error occurred creating the configuration section handler for nlog: Exception occurred when loading configuration from D:\InetPub\wwwroot\WEBFRONT\web.config

Source Error:


Line 8:      <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
Line 9:    </configSections>
Line 10:   <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsf="http://www.w3.org/2001/XMLSchema-instance" throwException="true">
Line 11:     <targets>
Line 12:       <target name="HttpModuleFile" xsf:type="File" layout="${date:format=HH\:mm\:ss} - ${level} - ${callsite:includeSourcePath=false} - ${message}" fileName="D:\logs\GST.Extranet\HttpMolues.log" archiveFileName="D:\logs\GST.Extranet\archives\HttpModules{#####}.log" archiveEvery="Day" archiveNumbering="Rolling" keepFileOpen="false" encoding="iso-8859-2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
 

Source File: D:\InetPub\wwwroot\WEBFRONT\web.config    Line: 10

Not very clear but in the Windows Event Viewer I got more details:
Exception occurred when loading configuration from D:\InetPub\wwwroot\WEBFRONT\web.config
   at NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader, String fileName, Boolean ignoreErrors)
   at NLog.Config.XmlLoggingConfiguration..ctor(XmlElement element, String fileName)
   at NLog.Config.ConfigSectionHandler.System.Configuration.IConfigurationSectionHandler.Create(Object parent, Object configContext, XmlNode section)
   at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader, String filename, Int32 line)

Parameter xsi not supported on FileTarget
   at NLog.Internal.PropertyHelper.SetPropertyFromString(Object o, String name, String value, ConfigurationItemFactory configurationItemFactory)
   at NLog.Config.XmlLoggingConfiguration.ConfigureObjectFromAttributes(Object targetObject, NLogXmlElement element, Boolean ignoreType)
   at NLog.Config.XmlLoggingConfiguration.ParseTargetElement(Target target, NLogXmlElement targetElement)
   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)

It loooks like the xsi namespace alias is not recognize.
Is it something to do with the fact that the namespace indicates an URL (http://www.w3.org/2001/XMLSchema-instance) which is maybe blocked since our machine is part of a DMZ with strict firewall rules ?

Thanks for your expertise guys :-)))
Reply | Threaded
Open this post in threaded view
|

Re: Parameter xsi not supported on FileTarget

Jason LaFlair
Administrator
I'm seeing a difference between your posted config and your error log message.

Config:
  <nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

Log Message:
Line 10:   <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsf="http://www.w3.org/2001/XMLSchema-instance" throwException="true">

I would just double check that - maybe I'm just seeing a cut/paste issue here too.
Reply | Threaded
Open this post in threaded view
|

Re: Parameter xsi not supported on FileTarget

Geofrey
The diffenrence you mentioned is because I tried many things by myself; But even if I have the exacly same node attributes for <nlog>, the problem remains the same :-<

My alternative is to separate the "nlog" section outside the app.config and to put it in a NLog.config file, but it's not my ideal solution. I would prefer to keep it the app.config since with Config Transformation features, I could easly change the nlog config depending of the target environment (Debug, Validation, Production).

Any other idea ?

Geofrey
Reply | Threaded
Open this post in threaded view
|

Re: Parameter xsi not supported on FileTarget

Jason LaFlair
Administrator
Have you tried just removing them?

change

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsf="http://www.w3.org/2001/XMLSchema-instance" throwException="true">

to just

<nlog throwException="true">