2013-07-04 18 views
13

bulamayan Bu benim hata iletisi:log4net yapılandırma - bölüm

log4net:ERROR XmlConfigurator: Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the <log4net> and <configSections> elements. The configuration section should look like: <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> 

bu benim web.config geçerli:

<?xml version="1.0"?> 
<configuration> 
    <configSections> 
     <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> 
    </configSections> 

    <system.serviceModel> 
    ... 
    </system.serviceModel> 

    <connectionStrings> 
    ... 
    </connectionStrings> 

    <log4net> 
    ... 
    </log4net> 

</configuration> 

benim yapılandırma ile yanlış nedir?

Güncelleme:

da Web.Release.config Var:

<?xml version="1.0"?>  
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 

    <system.web> 
     <compilation xdt:Transform="RemoveAttributes(debug)" /> 
    </system.web> 

    <system.serviceModel> 
    ... 
    </system.serviceModel> 

    <connectionStrings> 
    ... 
    </connectionStrings> 

    <log4net> 
    ... 
     <root> 
      <level value="DEBUG" xdt:Transform ="Replace"/> 
     </root> 
    </log4net> 

</configuration> 

Web.Test.cofig - Release bir

ve Web.Debug.config aynı, yani boş:

<?xml version="1.0"?> 

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">  

</configuration> 
+0

Bu hata iletisine sahibim ancak Logger'ım düzgün çalışıyor. – MikroDel

cevap

5

Hiçbir şey def ile yanlış görünüyor <configSections>'un altındaki bölümü girerek.

Projenizin özellikler klasöründeki AssemblyInfo.cs öğenize [assembly: log4net.Config.XmlConfigurator(Watch = true)] eklemeyi deneyin. Bu, yapılandırmanızın etiketin altında olması durumunda hile yapmalıdır.

DÜZENLEME:

XmlElement log4NetSection = (XmlElement)ConfigurationManager.GetSection("log4net"); 
      log4net.Config.XmlConfigurator.Configure(log4NetSection); 
+0

Cevabınız Siraj için teşekkürler. Denedim ve hiçbir şey olmadı - aynı hata mesajı – MikroDel

+0

Düzenlemeyi kontrol et ve "AppStart" daki kod parçasını dene ya da uygulamada nokta yürütme başlıyor –

+0

System.configuration aksamına referans eklemeyi unutma. ve "System.Configuration kullanarak" –

17

bir yere XmlConfigurator.Configure() diyorsun?

Bu çağrıları kaldırın ve yalnızca [assembly: log4net.Config.XmlConfigurator(Watch = true)] özniteliğini ekleyin.

Normalde log4net'i ayrı bir dosyada yapılandırmak daha kolaydır. senin web.config yılında Kaldır bölümünde

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)] 

: Bir dosya log4net.config oluşturun ve sizin niteliğini değiştirmek.

+0

"XmlConfigurator.Configure() bir yeri arıyor musunuz?" - Hayır – MikroDel

+0

Bu çalıştı. Sanırım XmlConfigurator.Configure() artık kullanılmıyor mu? Her zaman böyle yaptım. Assembly.cs'yi asla değiştirmek zorunda kalmamıştım. En son dokümanları okumalıyım. –