Initialization module using log4net directly disables logging

Found in

EPiServer.CMS.Core 11.1.0

Fixed in

EPiServer.Logging.Log4Net 2.2.1

Created

Jan 22 2018

Updated

Jun 27 2018

Area

CMS Core

State

Closed, Fixed and tested


Description

  1. Add the following intialization module:

        [InitializableModule]
        public class AA : IInitializableModule
        {
            private static readonly log4net.ILog _log = log4net.LogManager.GetLogger("test");
     
            public void Initialize(InitializationEngine context)
            {}
     
            public void Uninitialize(InitializationEngine context)
            {}
        }
    

EXPECTED: Logging works
ACTUAL: Logging stops working

Note: Sometimes for this bug fix to take affect you have to clear "Temporary ASP.NET Files", ie C:\Windows\Microsoft.Net\Framework64\v4.0.30319\Temporary ASP.NET Files\

WORKAROUND: An easy fix is to use namespace EPiServer.Logging.Compatiblity instead of log4net, to make sure log4net can be safely initialized from CMS instead from a custom initialization module.