Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unrecognized configuration section log4net. web.config website

Tags:

asp.net

I use log4net to log the errors in my web application and it works fine. However if I place the same code in website I get error "Unrecognized configuration section log4net"

here is my web.config section

<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" requirePermission="false"/>  

<root>

  <level value="RELEASE" />

  <appender-ref ref="LogFileAppender" />

</root>

<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" >

        <param name="File" value="D:\ESSReport\Logs\ESSlog.log" />

        <param name="AppendToFile" value="true" />

  <rollingStyle value="Size" />

  <maxSizeRollBackups value="5" />

  <maximumFileSize value="4MB" />

  <staticLogFileName value="true" />

  <layout type="log4net.Layout.PatternLayout">

   <param name="ConversionPattern" value="%newline%-5p%d{yyyy-MM-dd hh:mm:ss} [%thread] [%logger] [%line] %newline - %message"  />

  </layout>

</appender>

I have added dll to my website

like image 710
Somashekhar Avatar asked Jun 13 '12 08:06

Somashekhar


1 Answers

You are probably missing configuration section registration.

Here is sample code how you can register custom section:

<configuration>
  <configSections>
    <sectionGroup name="LoggerConfiguration">
      <section name="GPWFLogger" type="GP.Solutions.WF.Entities.LoggerConfiguration,GPWFLogger" allowDefinition="Everywhere" allowLocation="true"/>
    </sectionGroup>
  </configSections>

  <LoggerConfiguration>
    <GPWFLogger
      ConnectionStringName="ASPNETDB"
      LogLevel="Full"
      LogPrimaryTarget="SqlServer"
      LogFilePath="GPWFwebClient.log" />     
  </LoggerConfiguration>

Take notice that LoggerConfiguration is registred inside sectionGroup. You can use this principle in your case.

like image 174
Gregor Primar Avatar answered Sep 22 '22 05:09

Gregor Primar