Unrecognized log4net configuration section. Website web.config

I use log4net to log errors in my web application and it works great. However, if I post the same code on the website, I get the error message "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 added dll to my site

+8
source share
1 answer

You may not be able to register the configuration section.

Here is a sample code on how you can register a user 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> 

Note that LoggerConfiguration is registered inside the Group section. You can use this principle in your case.

+10
source share

All Articles