1
votes

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.

2

2 Answers

2
votes

There is an age-old bug in episerver logging: if you have a static (class level) log4net log object declared in your global.asax, none of your custom logging will work, only episerver internal logging.

If you need to log stuff in global.asax declare the logger inside the methods. In other classes you can declare it statically as usual.

0
votes

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.