I use log4net in the included WCF service with WCM hosted in IIS 7. I use Ninject to inject dependencies and install Ninject.Extensions.Wcf , Ninject.Extensions.Logging.log4net NuGet and the log4net configuration section is added to the Web.config file.
I have seen people suggest adding log4net initialization code to Global.asax, but this does not work for activated MSMQ services, as far as I can tell. However, Ninject installs the WebActivator package, which allows you to run the initialization code when the web application starts. Ninject puts its own code in App_Start \ NinjectWebCommon.cs . To configure log4net, you need to add code to the Start method. My looks like this:
public static void Start() { DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule)); DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
source share