'log4net on a dynamically loaded dll doesn't log

> I have a DLL that I am dynamically loading at run time. My log4net is logging fine before and after the loading of the DLL but it is not logging anything within the DLL it's self. I have created a test stub application that uses the same DLL and it will log fine. Is there any specific in the config I need to set to get log4net to work when dynamically loaded?

        /// <summary>
    /// Setting the Scanning Module
    /// </summary>
    private MyAPpLibrary.Helpers.LoaderAssembly _executingModule;
    public MyAPpLibrary.Helpers.LoaderAssembly executingModule
    {
        get
        {
            if(_executingModule == null)
            {
                
                try
                {
                    _executingModule = (MyAPpLibrary.Helpers.LoaderAssembly)appDomain
                                        .CreateInstanceAndUnwrap(typeof(MyAPpLibrary.Helpers.LoaderAssembly).Assembly.FullName, 
                                        typeof(MyAPpLibrary.Helpers.LoaderAssembly).FullName);

                    _executingModule.ModuleName = ScanModuleAssembly;
                    _executingModule.LoadAssembly(Path.Combine(Path.Combine(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath, "Bin", ScanModuleAssembly)));
                    
                }
                catch(Exception er)
                {
                    log.Error(er);
                }

            }

            return _executingModule;
        }
        set
        {
            if ((_executingModule != value))
            {
                _executingModule = value;
            }
        }
    }

Call to load the DLL Dynamically

executingModule.ExecuteStaticMethod(ScanModuleAssembly, "FormOCRProcess", objParams);

Setting log4net in loaded DLL.

        private static ILog _log;
    public static ILog log
    {
        get
        {
            if (_log == null)
            {
                log4net.Config.XmlConfigurator.Configure();
                _log = LogManager.GetLogger("ScanningModule");
            }

            return _log;
        }
    }

module being loaded dynamically .confg file

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
  </configSections>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="itextsharp" publicKeyToken="8354ae6d2174ddca" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.5.13.0" newVersion="5.5.13.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <log4net debug="true">
    <!-- Define some output appenders -->
    <appender name="MyApp" type="log4net.Appender.FileAppender,log4net">
      <param name="File" value="Logs/CertifiTracWeb.log" />
      <param name="AppendToFile" value="true" />
      <param name="RollingStyle" value="Date" />
      <param name="DatePattern" value="yyyy.MM.dd" />
      <param name="maximumFileSize" value="1MB" />
      <param name="maxSizeRollBackups" value="5" />
      <param name="StaticLogFileName" value="true" />
      <layout type="log4net.Layout.PatternLayout,log4net">
        <param name="ConversionPattern" value="%d [%t] %-5p %c %logger  %property{user}  - %m%n" />
      </layout>
    </appender>
    <!-- Setup the root category, add the appenders and set the default priority -->
    <root>
      <priority value="INFO" />
    </root>
    <logger name="ScanningModule" additivity="true">
      <level value="ON" />
      <appender-ref ref="MyApp" />
    </logger>
</configuration>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source