NLog Configuration system failed to initialize
I am new to Nlog, Put the Nlog Configuration in the app.config file below the configuration section, and de开发者_开发百科fine a section name inside the Config Section but still I get this error "Configuration system failed to initialize". The below is the contents of my app.config file.
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</sectionGroup>
</configSections>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="console" xsi:type="Console"
layout="${date:format=HH\:mm\:ss} ${level:uppercase=true} ${logger} 
${message} ${exception:format=message,type,stacktrace}"
/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="console" />
</rules>
</nlog>
</configuration>
I moved the nlog outside of the sectionGroup since it is not a member of the applicatinSettings tag. Sorry my fault.
This is not much of an answer, but have you tried turning on NLog's internal logging?
You can do it in the config file like this:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
internalLogLevel="Trace|Debug|Info|Warn|Error|Fatal"
internalLogFile="NLogInternal.log"
throwExceptions="true"
autoReload="true">
<!-- Rest of NLog config stuff goes here -->
</nlog>
You might also try using a separate NLog.config file and see if that works. One advantage to this approach (using NLog.config) is that if you can get it to work, you should be able to pretty much just copy the contents of the NLog.config into the app.config (if you would rather have NLog's config information in the app.config file rather than in the NLog.config file).
ADDED:
What is with the strange characters in your NLog configuration between ${logger}
and ${message}
? Could they be part of the problem?
I got it to work by adding the following attributes to my NLog tag in the Nlog.config file:
throwExceptions="false"
I had also included the following attribute for a build transform issue: xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"
精彩评论