Try our conversational search powered by Generative AI!

Logging stopped working after latest epi upgrade


We upgraded from episerver 10 -> 11 (the release that came out 5 february) and logging for us stopped working. After a lot of investigating we are seeing that our appenders from EPIServerLog.config is not beeing loaded. When we add these lines at the top of our InitializationModule we can get it to work. But this is not the solution ofc, does someone know what has happend?

var fileInfo = new FileInfo($@"{HostingEnvironment.ApplicationPhysicalPath}\EPiServerLog.config");



Edited, Feb 14, 2018 14:27

We're seeing the same problems after upgrading EPiServer.Logging.Log4Net from 2.2.0 to 2.2.1. Downgrading to 2.2.0 made logging work again. The bug is reported to Episerver.

Feb 14, 2018 16:49

If your code is using this

using log4net;

try this
using EPiServer.Logging.Compatibility;

You may be suffering from  

Feb 14, 2018 16:51

Yeah, but seems that the issue is still there since we are running the version that the bug says it was fixed in.

And changing all our using does not seem like a solution surprisedsealed


Edited, Feb 15, 2018 13:59

Hi, we had the same issue. In our case this was caused by the fact there were calls in the initialization modules to log4net LogManager.GetLogger(your-type-here); This was done before episerver had configured log4net (calls to get loggers before any calls to EPiServer.Logging.Log4Net assembly which has the configuration attribute).

Quick fix without any code changes to initialization modules is to just apply the log4net configuration attribute to your web app assembly:

[assembly: XmlConfigurator(ConfigFile = "episerverlog.config", Watch = true)]

The real fix naturally is to stop using log4net directly but using the Episerver logging abstraction, namespace EPiServer.Logging and the LogManager there.

You should only use the EPiServer.Logging.Compatibility to "quickly" change direct calls to log4net instead to Episerver abstraction.

Feb 15, 2018 20:27

Same issue here. No loggers in any initialization modules what so ever and not using of log4net namespace. Logging just stopped working. Downgraded to 2.2.0 and it started to work again.

Feb 16, 2018 8:24

Hah, I had just tested the logging in local development in debug mode where it works. Checked our internal test - oooops no logs.

Reflector shows that Episerver has added a PreApplicationStartModule.PreApplicationStart() static method which calls log4net.LogManager(typeof(PreApplicationStartModule)); there goes the log4net configuration in release mode.

Here is the work around to have logging working again with 2.2.1:

<!-- add these entries to configure log4net -->
<add key="log4net.Config" value="EPiServerLog.config"/>
<add key="log4net.Config.Watch" value="True"/>
Feb 16, 2018 10:54

We have now figured out what caused this issue. The overload to GetLogger in log4net that was used from EPiServer.Logging.Log4Net called Assembly.GetCallingAssembly() and in released compiled code this was evaluated to mscorlib.
Reason for this is optimizations done by the compiler when doing release compilation.
We will try to get a fix out as soon as possible.

So the takeaway is be careful when using Assembly.GetCallingAssembly(), it might be different than expected due to compiler optimizations.

Feb 19, 2018 14:26

Awesome! cool Hope you can get it out real soon.

Feb 19, 2018 15:26

A new version of EPiServer.Logging.Log4Net is now released and available in the NuGet feed.

Feb 20, 2018 10:45

As Åsa says, this is now available

Feb 20, 2018 11:17
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.