November Happy Hour will be moved to Thursday December 5th.

Logging stopped working after latest epi upgrade

Vote:
 

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");

XmlConfigurator.Configure(fileInfo);

//T

#188206
Edited, Feb 14, 2018 14:27
Vote:
 

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.

#188209
Feb 14, 2018 16:49
Vote:
 

If your code is using this

using log4net;

try this
using EPiServer.Logging.Compatibility;

You may be suffering from https://world.episerver.com/support/Bug-list/bug/CMS-9555  

#188210
Feb 14, 2018 16:51
Vote:
 

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

//T

#188246
Edited, Feb 15, 2018 13:59
Vote:
 

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.

#188257
Feb 15, 2018 20:27
Vote:
 

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.

#188258
Feb 16, 2018 8:24
Vote:
 

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:

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

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.

#188309
Feb 19, 2018 14:26
Vote:
 

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

#188313
Feb 19, 2018 15:26
Vote:
 

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

#188331
Feb 20, 2018 10:45
Vote:
 

As Åsa says, this is now available

https://world.episerver.com/releases/episerver---update-202/

#188335
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.