log4net configuration error - cant find app.config

I am trying to implement log4net in a helper project (AC.Helpers), and when it runs the configuration, I get the following error in the Output window -

log4net:ERROR Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the and elements. The configuration section should look like:

LoggerBase.cs -

public abstract class LoggerBase
{
    #region Member Variables

    /// <summary>
    /// Member variable to hold the <see cref="ILog"/> instance.
    /// </summary>
    private readonly log4net.ILog logger = null;

    #endregion

    #region Properties

    /// <summary>
    /// Abstract property which must be overridden by the derived classes.
    /// The logger prefix is used to create the logger instance.
    /// </summary>
    protected abstract System.Type LogPrefix
    {
        get;
    }

    #endregion

    #region Constructors

    private static bool isConfigured = false;
    /// <summary>
    /// Constructor of the class.
    /// </summary>
    public LoggerBase()
    {
        // initiate logging class           
        if (!isConfigured)
        {
            log4net.Config.XmlConfigurator.Configure();
            isConfigured = true;
        }
        logger = log4net.LogManager.GetLogger(this.LogPrefix);
    }

    #endregion

App.config -

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

  <log4net>
    <appender name="Console" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date %-5level: %message%newline" />
      </layout>
    </appender>

    <root>
      <level value="INFO" />
      <appender-ref ref="Console" />
    </root>
  </log4net>
</configuration>

Any ideas why I am getting this? Other posts suggest moving the log4net config to its own file and use the following in AssemblyInfo.cs (tried, without success)

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]

Answers


Need Your Help


About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.