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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With