kaspatoo

log4net:ERROR XmlConfigurator

Discussion created by kaspatoo on Mar 14, 2011
Latest reply on Jun 7, 2011 by kaspatoo
Hello,

I want to use log4net within my addIn for ArcMap 10.
The same code, just another class name, is functioning within an non-addIn Project, lika a console application.
I'm using log4net.dll v. 1.2.10.

The AddIn is integratet into my toolbar on arcMap.
But this error occurs when executing the addIn:

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" />


This is my "App.config":

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>
  
  <log4net>

    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="C:\\test.txt" />
      <appendToFile value="true" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="10MB" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n" />
      </layout>
    </appender>

    <root>
      <level value="DEBUG" />
      <appender-ref ref="RollingLogFileAppender" />
    </root>


  </log4net>
  
</configuration>


That is my test Add-In:

namespace ArcMapAddin1
{
    public class KoordinatenLesen : ESRI.ArcGIS.Desktop.AddIns.Button
    {
        static log4net.ILog logger = null;
                
        public KoordinatenLesen()
        {
            log4net.Config.XmlConfigurator.Configure();
            logger = LogManager.GetLogger(typeof(KoordinatenLesen));
            logger.Info("Start");
        }

        protected override void OnClick()
        {        
            Enabled = ArcMap.Application != null;
        }
    }

}


Another logging-statements will be ignored.

Outcomes