Search code examples
c#log4netepiserver

log4net is not logging custom logs in EPiServer


I have issue with log4net in EPiServer. It is logging EPiServer stuff, NHibernate stuff, but not my custom logs. Tried to explicitly configure logger to log everything in my namespace:

<logger name="My.Website.Business">
    <level value="All" />
</logger>

I am defining logger in my custom class like this:

ILog log = LogManager.GetLogger(typeof(MyClass));

And call it like this:

log.Error("Some error");

I also enabled log4net logging itself to see what happens on startup, but there are no errors or strange behaviour. It even creates logger defined in config. I also tried to define other appender for my logger, but it just creates empty file and doesn't log anything.


Solution

  • The reason why log4net didn't work was different versions of log4net. My application referenced log4net 1.2.11 (2.0.0), but EPiServer work with 1.2.10. We are using NuGet to install/update packages and someone updated log4net to newer version. So be aware to use same log4net version for EPiServer and application.