C# Microsoft.Practices.EnterpriseLibrary.Logging error

本文关键字:Logging error EnterpriseLibrary Practices Microsoft | 更新日期: 2023-09-27 18:08:20

当我尝试使用microsoft . practicesenterpriselibrarylogging

时,我得到一个错误

"microsoft . practices . enterpriselilibrary . logging"的类型初始化器。日志'抛出异常。

<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>

任何帮助都将不胜感激

感谢k

C# Microsoft.Practices.EnterpriseLibrary.Logging error

我遇到了这个问题,花了很长时间后,如果发现在我的配置中,"configSection"的声明应该是第一个标签。如果在它之前有任何其他标记,则抛出相同的错误。

在我的例子中,在我的configsection之前有一个目标框架标签。我把它移到后面,它开始工作了