views:

71

answers:

1

My App.config is given below. The file is the same project as the calls to :

log4net.Config.XmlConfigurator.Configure();
private static log4net.ILog Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

However I am receiving

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 n
ame="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /

I feel like I am making a stupid mistake as I am just starting with log4net. Any help on this?

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

 <log4net>

<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
  <file value="C:\log-file.txt" />
  <appendToFile value="true"/>
  <rollingStyle value="Size" />
  <maximumFileSize value="1MB" />
  <staticLogFileName value="true" />
  <maxSizeRollBackups value="10" />
  <conversionPattern value="%date [%thread] %-5level %location %logger -    %message%newline" />
  <layout type="log4net.Layout.SimpleLayout" />
</appender>

<root>
       <level value="ALL" />
       <appender-ref ref="RollingFileAppender" />
</root>

+1  A: 

The only thing I see right away in your web.config is that you're missing the closing tag.

Byron Sommardahl