2011-09-13 43 views
2

我得到一個錯誤,當我試圖使用Microsoft.Practices.EnterpriseLibrary.LoggingC#Microsoft.Practices.EnterpriseLibrary.Logging錯誤

的類型初始爲「Microsoft.Practices.EnterpriseLibrary.Logging.Logger」拋出例外。

<configSections> 
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" /> 
    </configSections> 
    <loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="Tracing" logWarningsWhenNoCategoriesMatch="true"> 
    <listeners> 
     <add fileName="F:\Service\Service\log\Full\Service.log" rollSizeKB="1024" timeStampPattern="yyyy-MM-dd" rollFileExistsBehavior="Increment" rollInterval="None" formatter="Text Formatter" header="" footer="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" traceOutputOptions="LogicalOperationStack" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" name="AppLog" /> 
    </listeners> 
    <formatters> 
     <add template="{timestamp} : {message}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" name="Text Formatter" /> 
    </formatters> 
    <categorySources> 
     <add switchValue="All" name="AppLog"> 
     <listeners> 
      <add name="AppLog" /> 
     </listeners> 
     </add> 
     <add switchValue="Verbose" name="ExceptionHandling"> 
     <listeners> 
      <add name="Exception" /> 
     </listeners> 
     </add> 
     <add switchValue="Information" name="Tracing"> 
     <listeners> 
      <add name="Trace" /> 
     </listeners> 
     </add> 
    </categorySources> 
    <specialSources> 
     <allEvents switchValue="All" name="All Events" /> 
     <notProcessed switchValue="All" name="Unprocessed Category" /> 
     <errors switchValue="Off" name="Logging Errors Warnings" /> 
    </specialSources> 
    </loggingConfiguration> 

任何幫助將不勝感激

感謝

ķ

回答

1

我面對這個問題,之後花費很長的時間,如果發現在我的配置,「configSection」的聲明應該是第一個標籤。如果之前有任何其他標籤,則會引發相同的錯誤。

在我的情況下,在我的configsection之前有目標框架標記。我把它移到那之後,它開始工作